Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Grupo: 4BM1
para la funcin
desarrollamos el siguiente
cdigo:
>> f=vectorize(inline('1/(1+x^2)'))
f=
0 -1
>> P=c(1)+c(2)*(x-a)+c(3)*(x-a)^2
Inline function:
P=
f(x) = 1./(1+x.^2)
1 - x^2
>> a=0;
>> syms x
>> c(1)=f(a)
%PARA
c=
GRAFICAR
TENEMOS
EL
SIGUIENTE
CODIGO
1
>> x=-1:0.01:1;
>> c(2)=subs(diff(f(x)),a)/factorial(1)
>> plot(x,f(x))
c=
>> hold on
1
0
>> g=ezplot(P,[-1,1]);
>> c(3)=subs(diff(f(x),2),a)/factorial(2)
>> set(g,'color',[.9,.2,.3],'LineWidth',2)
>> grid on
c=
>>
legend('f(x)','P')
c=
1
Inline function:
>> c(3)=subs(diff(f(x),2),a)/factorial(2)
f(x) = 1./(1+x.^2)
c=
>> a=0;
0 -1
>> syms x
>> c(4)=subs(diff(f(x),3),a)/factorial(3)
>> c(1)=f(a)
c=
c=
1
>> c(2)=subs(diff(f(x)),a)/factorial(1)
0 -1
>> c(5)=subs(diff(f(x),4),a)/factorial(4)
c=
1
0 -1
>>
P=c(1)+c(2)*(x-a)+c(3)*(x-a)^2+c(4)*(x-
a)^3+c(5)*(x-a)^4
P=
x^4 - x^2 + 1
DONDE EL POLINOMIO DE TAYLOR DE
>> x=-1:0.01:1;
>> plot(x,f(x))
>> hold on
>> g=ezplot(P,[-1,1]);
>> set(g,'color',[.9,.7,.3],'LineWidth',3)
CUARO GRADO ES
>> grid on
>> legend('f(x)','P4')
% y para graficar el mismo cdigo
1. Para la funcin
grado entorno a
. Grafique la
absoluto y relativo.
>> f=vectorize(inline('tanh(x+1)'))
>> c(5)=subs(diff(f(x),4),a)/factorial(4)
f=
c=
Inline function:
0 1.0000
f(x) = tanh(x+1)
0 -0.3333
>> c(6)=subs(diff(f(x),5),a)/factorial(5)
>> a=-1;
c=
>> syms x
1.0000
-0.3333
0.1333
>> c(1)=f(a)
>>
c=
P=c(1)+c(2)*(x-a)+c(3)*(x-a)^2+c(4)*(x-
a)^3+c(5)*(x-a)^4+c(6)*(x-a)^5
0
P=
>> c(2)=subs(diff(f(x)),a)/factorial(1)
x - (x + 1)^3/3 + (2*(x + 1)^5)/15 + 1
c=
0
>> c(3)=subs(diff(f(x),2),a)/factorial(2)
c=
0
>> x=-3:0.01:1;
1
>> plot(x,f(x))
>> c(4)=subs(diff(f(x),3),a)/factorial(3)
>> hold on
c=
>> g=ezplot(P,[-3,1]);
0 1.0000
0 -0.3333
>> set(g,'color',[.9,.7,.6],'LineWidth',3)
>> grid on
>> error_a=abs(f(.5)-subs(P,.5))
error_a =
21723191451464877/45035996273704960
>> vpa(expand(error_a),5)
ans =
0.48235
>>
legend('f(x)','P5')
>> vpa(expand(error_r),5)
ans =
0.5329
1. Sea la funcin
grado alrededor de
para la funcin
-3.6952 4.4635
>> Pa=ca(1)+ca(2)*(x-a)
Pa =
(2512700461189009*x)/562949953421312 - 4160401663039155/1125899906842624
>> vpa(expand(Pa),5)
ans =
4.4635*x - 3.6952
>> cb(1)=f(b)
cb =
-1.8730
>> cb(2)=subs(diff(f(x)),b)/factorial(1)
cb =
-1.8730 2.9238
>> Pb=cb(1)+cb(2)*(x-b)
Pb =
(3291904515712049*x)/1125899906842624 - 7509520127029801/2251799813685248
>> vpa(expand(Pb),5)
ans =
2.9238*x - 3.3349
>> cc(1)=f(c)
cc =
-0.6945
>> cc(2)=subs(diff(f(x)),c)/factorial(1)
cc =
-0.6945 1.8473
>> Pc=cc(1)+cc(2)*(x-c)
Pc =
(4159668786720471*x)/2251799813685248 - 5723606919105669/2251799813685248
>> vpa(expand(Pc),5)
ans =
1.8473*x - 2.5418
>> x=-1:0.01:2;
>> k=plot(x,f(x));
>> set(k,'color',[.9,.3,.9],'LineWidth',4)
>> grid on
>> hold on
>> g=ezplot(Pa,[-1,2]);
>> set(g,'color',[.9,.9,.0],'LineWidth',3)
>> h=ezplot(Pb,[-1,2]);
>> set(h,'color',[.9,.7,.6],'LineWidth',3)
>> i=ezplot(Pc,[-1,2]);
>> set(i,'color',[0,.7,.6],'LineWidth',3)
>> legend('f(x)','Pa','Pb','Pc')
>> x=-1:0.01:2;
k=plot(x,f(x));
set(k,'color',[.9,.3,.9],'LineWidth',4)
grid on
hold on
g=ezplot(Pa,[-1,2]);
set(g,'color',[.9,.9,.0],'LineWidth',3)
h=ezplot(Pb,[-1,2]);
set(h,'color',[.9,.7,.6],'LineWidth',3)
i=ezplot(Pc,[-1,2]);
set(i,'color',[0,.7,.6],'LineWidth',3)
legend('f(x)','Pa','Pb','Pc')