### Generaremos El Polinomio Cos (X) : Import As From Import Import As Import From Import As

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

8/3/22, 18:27 Untitled80 - Jupyter Notebook

In [122]: import numpy as np


from numpy import cos
import matplotlib.pyplot as plt
import math
from numpy import pi as pi

In [129]: ### generaremos el polinomio cos(x)


def suma(x,n,a):
return ((-1)**n)*(((x-a)**(2*n))/(math.factorial(2*n)))

In [130]: # definimos los intevalos


x=np.linspace(-2*pi,2*pi,100)
y = cos(x)

In [131]: polinomio = 0

In [132]: # haremos la serie para n== 10


for i in range(0,4):
polinomio = polinomio +suma(x,i,0)

localhost:8890/notebooks/Untitled80.ipynb?kernel_name=python3 1/2
8/3/22, 18:27 Untitled80 - Jupyter Notebook

In [133]: # gráfica del sistema de ecuaciones creado:



fig = plt.figure(figsize=(12,7))
plt.plot(x,y,label=("cos(x)" ),color="red")
plt.plot(x,polinomio,label=("Serie tylor n=4,a=0" ),color="blue")

plt.grid()
plt.title("Grafica",fontsize=16)
plt.ylim(-5,5)
ax = plt.gca()

ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.spines['bottom'].set_position(('data', 0))
ax.spines['left'].set_position(('data', 0))
plt.legend(bbox_to_anchor=(1.05, 1.0), loc='upper left',fontsize=14)

Out[133]: <matplotlib.legend.Legend at 0x1ffde2334c0>

In [ ]: ​

In [ ]: ​

localhost:8890/notebooks/Untitled80.ipynb?kernel_name=python3 2/2

You might also like