Anul 3 Semestrul 2
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#1.b
|
||||
|
||||
|
||||
nodes = linspace(-2,4,10);
|
||||
f=@(x)(x+1)./(3*x.^2+2*x+1);
|
||||
|
||||
plot(nodes, f(nodes),'o');
|
||||
hold on
|
||||
|
||||
|
||||
x=linspace(-2,4,500);
|
||||
|
||||
|
||||
plot(x,f(x));
|
||||
hold on
|
||||
|
||||
lnf=lagrange_classic(nodes,f(nodes),x);
|
||||
|
||||
plot(x,lnf)
|
||||
|
||||
plot(x,abs(f(x)-lnf),'x')
|
||||
|
||||
|
||||
nodes = [81,100,121];
|
||||
|
||||
f_nodes = [9,10,11];
|
||||
|
||||
sqrt(118);
|
||||
lnf = lagrange_classic(nodes,f_nodes, [118]);
|
||||
|
||||
|
||||
nodes = [1980,1990,2000,2010,2020];
|
||||
f_nodes = [4451,5287,6090,6970,7821];
|
||||
|
||||
lnf = lagrange_barycentric(nodes, f_nodes, [2005,2015])
|
||||
|
||||
abs([6474,7405] - lnf)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user