Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Asignatura
Profesor
Facultad
2
r - Tlf: (+34) 968 27 88 00 -
Asignatura
% [CoLag condicion] = fitvand( [ 1.35 1.37 1.40 1.45 ], [ .1303 .1367 .1461 .1614
])
% Representación gráfica
plot(X,Y,'or');
hold on;
x_plot = linspace(min(X)*0.95*sign(min(X)),max(X)*1.05*sign(max(X)),100);
plot(x_plot,polyval(pol_interp,x_plot,'-'));
v = v(:);
n = length(v);
if n == 0
A = reshape(v, n, n);
return;
end
A = repmat(v, 1, n);
A(:, n) = 1;
A = cumprod(A, 2, 'reverse');
coeficientes_indet =
24.7563
3
r - Tlf: (+34) 968 27 88 00 -
Asignatura
-78.7524
59.5770
6.8051
cond =
138.7438
20
18
16
14
12
10
0
0 0.5 1 1.5 2 2.5
Donde pone coeficietes_indet son los coeficientes del polinomio interpolado ,y son esos resultados.
La cond , es el numero de condicion y por lo que vemos está mal condicionado.
4
r - Tlf: (+34) 968 27 88 00 -
Asignatura
>> x=(0:7)*pi/7
x=
Columns 1 through 5
Columns 6 through 8
>> y=2*(sin(x)).^2-1
y=
Columns 1 through 5
Columns 6 through 8
>> [coeficientes,cond]=fitvand(x,y)
coeficientes =
5
r - Tlf: (+34) 968 27 88 00 -
Asignatura
0.0000
-0.0654
0.6163
-1.7801
1.0477
1.5113
0.0867
-1.0000
cond =
1.9349e+06
>>
>> X2=(0:15)*pi/15
X2 =
Columns 1 through 12
Columns 13 through 16
>> Y2=2*sin(X2).^2-1
Y2 =
6
r - Tlf: (+34) 968 27 88 00 -
Asignatura
Columns 1 through 12
-1.0000 -0.9135 -0.6691 -0.3090 0.1045 0.5000 0.8090 0.9781 0.9781 0.8090
0.5000 0.1045
Columns 13 through 16
>> [coeficientes2,cond2]=fitvand(X2,Y2)
coeficientes2 =
0.0000
-0.0000
0.0000
-0.0000
0.0001
0.0001
0.0004
-0.0069
0.0006
0.0884
0.0002
-0.6668
0.0000
2.0000
0.0000
-1.0000
7
r - Tlf: (+34) 968 27 88 00 -
Asignatura
cond2 =
7.3874e+14
0.8
0.6
0.4
0.2
-0.2
-0.4
-0.6
-0.8
-1
0 0.5 1 1.5 2 2.5 3 3.5
8
r - Tlf: (+34) 968 27 88 00 -
Asignatura
a.
P = lagrangepoly(X,Y);
xx = -2.5:.01:2.5;
plot(xx,polyval(P,xx),X,Y,'or');
>> p
>> P
P=
9
r - Tlf: (+34) 968 27 88 00 -
Asignatura
>>
-1
-2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2
b.
10
r - Tlf: (+34) 968 27 88 00 -
Asignatura
x=
0 0.5000 1.0000
>> y=sin(pi*x/4);
>> p=lagrangepoly(x,y);
>> yy=0:0.1:1
yy =
Columns 1 through 5
Columns 6 through 10
Column 11
1.0000
>> p
p=
11
r - Tlf: (+34) 968 27 88 00 -
Asignatura
-0.1165 0.8236 0
>>
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
d.
12
r - Tlf: (+34) 968 27 88 00 -
Asignatura
>> x= 0:0.5:1
x=
0 0.5000 1.0000
>> y=sin(pi*x/4);
>> y
y=
0 0.3827 0.7071
>> [P,R,S]=lagrangepoly(x,y);
>> P
P=
-0.1165 0.8236 0
>> R
R=
3.5343
13
r - Tlf: (+34) 968 27 88 00 -
Asignatura
>> S
S=
1.4555
e=
1.0978
>> polyval(P,3.5343)
ans =
1.4555
>> plot(xx,sin(pi*xx/4),'r-',xx,polyval(P,xx),'b-');
14
r - Tlf: (+34) 968 27 88 00 -
Asignatura
1.5
0.5
-0.5
-1
-1.5
-2
-2.5
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
Como se ve la cota de error es elevada. Podemos deducir aquí que cuantos más nodos menor es
la tasa de error.
15
r - Tlf: (+34) 968 27 88 00 -
Asignatura
if (nargin == 3)
verbose = false;
end
if (nargin < 3)
help('newton_interpolation');
p = '';
return;
16
r - Tlf: (+34) 968 27 88 00 -
Asignatura
end
if (numel(interval) ~= 2)
error('bad interval');
end
a0 = interval(1);
b0 = interval(2);
fx = sym(eq);
x = linspace(a0, b0, degree + 1);
y = subs(fx, 'x', x);
if (verbose)
disp('The starting values are ...');
disp([x' y']);
end
if (verbose)
disp(strcat('The newton interpolating poly is formed', ...
' as \Sigma(a_i\Pi(x-x_j))'));
disp('a_i coefficients are ...');
disp(a);
end
17
r - Tlf: (+34) 968 27 88 00 -
Asignatura
end
if (a(i + 1) > 0)
p = strcat(p, '+', num2str(a(i + 1), precision), '*', v);
else
p = strcat(p, num2str(a(i + 1), precision), '*', v);
end
end
p = sym(p);
if (verbose)
disp('The polynomial is ...');
pretty(p)
end
18
r - Tlf: (+34) 968 27 88 00 -
Asignatura
p=
El hold on HOLD ON holds the current plot and all axis properties, including
the current color and linestyle, so that subsequent graphing commands
% add to the existing graph without resetting the color and linestyle.
19
r - Tlf: (+34) 968 27 88 00 -
Asignatura
exp(x)
0
-1 -0.5 0 0.5 1 1.5 2
x
Una grafica es cuando está sola y la otra cuando estan las dos , vemos que entre 0 y 1 son
precisamente las mismas , una vez que se salen ya dejan de ser iguales.
Y esta es la representacion que obtenemos.
20
r - Tlf: (+34) 968 27 88 00 -