Professional Documents
Culture Documents
LU e Lagrange
LU e Lagrange
[L U] = lu(A)
y = L\B';
a = U\y;
P = [0,0,1;0,1,0;1,0,0];
a = a'*P;
polyval(a, 0.2)
A =
L =
U =
ans = 1.4141
Time: 0.016495704650878906 seconds.
Polinomio de lagrange
n=2;
x = [0.1, 0.6, 0.8];
y = [1.221, 3.320, 4.953];
z=0.2;
p=0;
for i= 1:(n+1)
c=1;
d=1;
for j= 1:(n+1)
if i~=j
c = c*(z-x(j));
d = d*(x(i)-x(j));
end
end
p = p + y(i)* c/d
end
p = 0.83726
p = 2.8293
p = 1.4141