Anda di halaman 1dari 5

PROBLEMAS DE ANLISIS NUMRICO SUSTITUTORIO

1) PROBLEMA1: METODO NEWTON RAPHSON


Programa
% Calcula la raiz de una funcion por el metodo newton-raphson
clear
syms x
a=input('ingrese la funciona evaluar:');
f=inline(a);
derivada=diff(a,x);
df=inline(derivada);
x0=input('Ingrese el valor inicial: ');
EPS=input('Ingrese el criterio de convergencia: ');
EPS1=input('Ingrese el criterio de exactitud: ');
Imax=input('Ingrese el numero de iteraciones maximas: ');
I=0;
while (I+1)<Imax
x=x0-f(x0)/df(x0);
Ea=abs(x-x0);
if Ea<EPS
fprintf('el valor de la raiz es =%15.9f\n',x);
fprintf('\n\n la raiz sale por criterio de convergencia \n');
break
end
if abs(f(x))<EPS1;
fprintf('el valor de la raiz es =%15.9f\n',x);
fprintf('\n\n la raiz sale por criterio de exactitud \n');
break
end
I=I+1;
x0=x;
end
fprintf('\n\n N iteraciones =%2.0f\n',I);
fprintf(' el valor del error absoluto es=%15.9f\n',Ea);

El siguiente problema se desarrollo despejando la ecuacin e
igualandola a 0 para hallar el valor de r por el mtodo de newton
Raphson

Imagen de la corrida para el problema 1









PROBLEMA 3: METODO EULER
EL PROGRAMA CONSISTE EN 3 FUNCIONES Y UN PROGRAMA y SE
DESARROLLO SEGN EL ALGORITMO DADO EN CLASE
1) function [dydx]=Derivs(cf,x,y)
f=inline(cf,'x','y');
dydx=f(x,y);
end

2) function [x,ynew]=Euler(cf,x,y,h)
[dydx]=Derivs(cf,x,y);
ynew=y+dydx*h;
x=x+h;
end

3) function [x,y,h]=integrator(cf,x,y,h,xend)
while x<xend
if h>=(xend-x)
h=xend-x;
end
[x,ynew]=Euler(cf,x,y,h);
y=ynew;
fprintf('\n\t %9.6f\t\t %9.6f\n', x,y);
end
end

4) %Programa principal
%Mtodo de Euler Mejorado
n=input('ingrese # de ecuaciones:');
y=input('Ingrese el valor Inicial yi:');
xi=input('Ingrese el valor Inicial xi:');
xf=input('Ingrese el valor inicial xf:');
dx=input('ingrese tamao de paso:');
xout=input('ingrese xout:');
cf=input('ingrese la ecuacion : ');
x=xi;
m=0;
xpm=x;
ypm=y;
disp( ' x y')
fprintf('%9.6f \t %9.6f\n',x,y)
while x<xf
xend=x+dx;
if xend>xf
xend=xf;
end
h=dx;
[x,y,h]=integrator(cf,x,y,h,xend);
m=m+1;
xpm=x;
ypm=y;
end

EN LA SIGUIENTE PGINA SE MOSTRARA LA IMAGEN DE LA CORRIDA PARA EL
PROBLEMA 3:
Este problema se desarroll considerando que la =

y luego
con la ecuacin ya formada se procedi a desarrollar el mtodo Euler
Se evalu de un tiempo cero hasta un tiempo 100 para encontrar la velocidad
mxima, en el t=40 se muestra la velocidad mxima y ya no vara el resultado como
se puede observar en el tiempo 41 y 42

Anda mungkin juga menyukai