Sunteți pe pagina 1din 2

METODOS NUMERICOS

RESOLVER EN MATLAB LA SERIE


SOLUCION:
PRIMER PASO CREAMOS LA FUNCION:










SEGUNDO PASO EJECUTAMOS LA FUNCION







AHORA TOMANDO VALORES v=2
TENEMOS


! 3 ! 2
1
3 2
x x
x e
x
function [ v,ea,iter ] = IterMeth( x,es,maxit
)
% initialization
iter=1;
sol=1;
ea=100;
% iterative calculation
while(1)
solold = sol;

sol = sol + x ^ iter / factorial (iter);
iter = iter + 1;
if sol~=0
ea=abs ((sol-solold)/sol)*100;
end
ifea<=es || iter>=maxit , break ,end

v =sol;
end
%UNTITLED Summary of this function goes here
% Detailedexplanationgoeshere




>>format long
>> [v, eaiter]= IterMeth(1,1e-6,100)
v =
2.718281801146385
ea =
9.216155641522974e-007
iter =
12
>> [v,eaiter]= IterMeth(2,1e-6,100)
v =
7.389056070325911
ea =









AHORA TOMANDO VALORES v=3
TENEMOS

>>format long
>> [v,eaiter]= IterMeth(3,1e-6,100)
v =
20.085536851451131
ea =

3.012715473536321e-007
iter =

19

S-ar putea să vă placă și