Escolar Documentos
Profissional Documentos
Cultura Documentos
n−1
pn (x)=( x−x 0 )(x−x 1)⋯(x−x n−1) = ∏ ( x−xi ) sendo n o número de raízes e o grau do
i=0
polinômio.
X = (2.5,4,5)
def poly(x):
P = 1
for i in range(len(X)):
P = P*(x-X[i])
return P
x= np.linspace(min(X),max(X))
y=[]
for t in x:
y.append(poly(t))
k = 2
X = (2.5,4,5)
def poly(k,x):
P = 1
for i in range(len(X)):
if i==k: continue
P = P*(x-X[i])
return P
x= np.linspace(min(X),max(X))
y=[]
for t in x: y.append(poly(k,t))
Polinômios de Lagrange.
n−1
( x−x 0 ) (x−x 1) (x−x k−1 ) (x−x k+ 1) (x−x n−1) (x−x )
Lk (x) = ⋯ ⋯
(x k −x 0) ( xk −x 1) (x k −x k−1) ( x k −x k+1 ) ( x k − xn−1 )
= ∏ (x −xi )
i=0 k i
i≠k
k = 1
X = (2.5, 4, 5)
def L(k,x):
P = 1
for i in range(len(X)):
if i==k: continue
P = P*(x-X[i])/(X[k]-X[i])
return P
x= np.linspace(min(X),max(X))
y=[]
for t in x:
y.append(L(k,t))
X = (2.5, 4, 5)
Y = ( 2, 0, 1)
def L(k,x):
P = 1
for i in range(len(X)):
if i==k: continue
P = P*(x-X[i])/(X[k]-X[i])
return P
def poly(x):
S = 0
for k in range(len(X)):
S = S + Y[k]*L(k,x)
return S
x= np.linspace(min(X),max(X))
y=[]
for t in x:
y.append(poly(t))
x 1 2 3 4
ln(x) 0 0.6931 1.0986 1.3863
Compare cada um dos resultados com o valor exato obtido chamando a função np.log(3.7)
diretamente.
2) A partir dos dados tabelados acima determine o valor de x tal que ln(x)=0.8