Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Programacion
Programacion
"UPS"
Nombre: Mateo Samaniego
Carrera: Mecánica Segundo G1
Fecha: 28/04/2018
Materia: Programación
Crear un programa que:
Genere una lista x con valores entre -3.14 y 3.14 con incrementos de 0.001
Genere una lista y1 con los valores de la tangente(x)
Genere una lista y2 con los valores de la cotangente(x)
Grafique la función tangente y1 en color azul
Grafique la función cotangente y2 en color amarillo
Tangente y Cotangente
import matplotlib.pylab as plt
import math
x=[]
y1=[]
y2=[]
j=-3.14
while j<=3.14:
x.append(j)
y1.append(j*math.tan(j))
y2.append(j*math.atan(j))
j+=0.001
print("X:", x)
print("Y1:", y1)
print("Y2:", y2)
plt.figure(figsize=(6,6))
plt.plot(x,y1,"b",label="x*tan(x)")
plt.plot(x,y2,"y*",label="x*atan(x)")
plt.xlabel("x")
plt.ylabel("f(x)")
plt.legend(loc="center")
plt.title("Tangente y Cotangente")
plt.show()
Tangente
import matplotlib.pylab as plt
import math
x=[]
y1=[]
j=-3.14
while j<=3.14:
x.append(j)
y1.append(j*math.tan(j))
j+=0.001
print("X:", x)
print("Y:", y1)
plt.figure(figsize=(4,4))
plt.plot(x,y1,"b",label="x*tan(x)")
plt.xlabel("x")
plt.ylabel("f(x)")
plt.legend(loc="center")
plt.title("Tangente")
plt.show()
Cotangente
import matplotlib.pylab as plt
import math
x=[]
y2=[]
j=-3.14
while j<=3.14:
x.append(j)
y2.append(j*math.atan(j))
j+=0.001
print("X:", x)
print("Y:", y2)
plt.figure(figsize=(4,4))
plt.plot(x,y2,"y",label="x*atan(x)")
plt.xlabel("x")
plt.ylabel("f(x)")
plt.legend(loc="center")
plt.title("Cotangente")
plt.show()