INSTITUTO POLITÉCNICO NACIONALUNIDAD PROFESIONAL INTERDISCIPLINARIA DE BIOTECNOLOGÍA
MÉTODOS NUMÉRICOS (TALLER)
GRUPO: 4AM1
TAREA 7
“ECUACIONES DIFERENCIALES”
REYES RODRÍGUEZ ALEJANDRO RUIZ HERNÁNDEZ BRENDA ANGÉLICA
PROFESOR:
RAMÍREZ BARRIOS MIGUEL LUIS
MÉXICO D.F. A 09 DE JULIO DE 2015
EJERCICIO 1
(x2+4 ) dydx
=2 x−8 xy
y(0)=1 en el intervalo [0,8]
Con h=0.01
t Euler Euler Modificada Range Analítica0.1 0,991800709275664 0,990993291209243 0,990993216665080
0,2500169676415331.5 0,372980400223570 0,373444493702320 0,3734340538236895 0,250251754878624 0,250267858695072 0,250267746193908
Con h=0.05
t Euler Euler Modificada Range Analítica0.1 0,988808428647307 0,983358212356027 0,983359660749962
0,2500166558882171.5 0,361688042229254 0,364525667846541 0,3642623586021565 0,250182932384893 0,250256253463751 0,250253435724293
%COMPARACIÓN DE LOS TRES MÉTODOS (ECUACIONES DIFERENCIALES)function [xr xp1 xp2 xp3 tp1]=Tarea7Ej1h=0.05;ti=0 %Condición Inicialtf=8x0=1 %Condición Final%Eulerx=x0;i=1;for t=ti:h:tf x=x+h*f1(x,t); xp1(i)=x; tp1(i)=t; i=i+1;end%Euler Modificadox=x0;i=1;for t=ti:h:tf x_aux=x+h*f1(x,t); x=x+(h/2)*(f1(x,t)+f1(x_aux,t+h)); xp2(i)=x; tp2(i)=t; i=i+1;end%Rangex=x0;i=1;for t=ti:h:tf k1=h*f1(x,t) k2=h*f1(x+0.5*k1,t+0.5*h); k3=h*f1(x+0.5*k2,t+0.5*h); k4=h*f1(x+k3,t+h); x=x+(1/6)*(k1+2*k2+2*k3+k4); xp3(i)=x; tp3(i)=t; i=i+1;endtr=ti:h:tf;xr=(tr.^8+16*tr.^6+96*tr.^4+256*tr.^2+1024)/(4*(tr.^2+4).^4); %Agregar la Solución de la Ecuaciónplot(tr,xr,'b');hold onplot(tp1,xp1,'k');plot(tp2,xp2,'r');plot(tp3,xp3,'g');legend('Analitica','Euler','Euler Modificado','Range 4to Orden')endfunction z=f1(x,t)z=(2*t-8*t*x)/(t^2+4); end
EJERCICIO 2
(e− y+1 ) sin ( x )dx=(1+cos ( x ))dyy(0)=0 en el intervalo [0,2]
Resolviendo para encontrar dydx
se obtiene:
dydx
=e− y (ey+1 ) sin (x)
cos ( x )+1
La solución de la Ecuación Diferencial es:
log(4/(1+cos(x))-1)
Con h=0.01
t Euler Euler Modificada Range Analítica0.1 0.00549593213728976 0.0060439524536017
00.00604392044175391 0,00549593213
71.5 1.01411923748938 1.00640902858382 1.01916684754578 1,01411923748
92 1.77799036217280 1.78494564701490 1.78493129113507 1,77799036217
2
Con h=0.05
t Euler Euler Modificada Range Analítica0.1 0,0112313692524073 0,0112290404385123 0,100000000000000 0,007498443099846
31.5 1,07123257093886 1,07107499599563 1,50000000000000 1,045226016289482 1,86014425899998 1,85975318791075 2 1,82390319253633
%COMPARACIÓN DE LOS TRES MÉTODOS (ECUACIONES DIFERENCIALES)function [xp1 xp2 xp3 tp1 tp2 tp3]=Tarea7Ej2h=0.05;ti=0 %Condición Inicialtf=2x0=0 %Condición Final%Eulerx=x0;i=1;for t=ti:h:tf x=x+h*f1(x,t); xp1(i)=x; tp1(i)=t; i=i+1;end%Euler Modificadox=x0;i=1;for t=ti:h:tf x_aux=x+h*f1(x,t); x=x+(h/2)*(f1(x,t)+f1(x_aux,t+h)); xp2(i)=x; tp2(i)=t; i=i+1;end%Rangex=x0;i=1;for t=ti:h:tf k1=h*f1(x,t) k2=h*f1(x+0.5*k1,t+0.5*h); k3=h*f1(x+0.5*k2,t+0.5*h); k4=h*f1(x+k3,t+h); x=x+(1/6)*(k1+2*k2+2*k3+k4); xp3(i)=x; tp3(i)=t; i=i+1;endtr=ti:h:tf;xr=log(4./(1+cos(tr))-1); %Agregar la Solución de la Ecuaciónplot(tr,xr,'b');hold onplot(tp1,xp1,'k');plot(tp2,xp2,'r');plot(tp3,xp3,'g');legend('Analitica','Euler','Euler Modificado','Range 4to Orden')endfunction z=f1(x,t)z=((exp(-x))*(exp(x)+1)*sin(t))/(cos(t)+1);end
EJERCICIO 3
x2 y '= y−xyy(-1)=1 en el intervalo [-1,0]
Con h=0.01
t Euler Euler Modificada Range Analítica-0.9 -1.25060658969911 -1.25422795089152 -1.25424502258329 -0.5197921531-0.5 -3.33226509572109 -3.39823319885161 -3.39855344722839 -0.9356258755
0 NaN NaN NaN Inf
Con h=0.05t Euler Euler Modificada Range Analítica
-0.9 -1.34092251461988 -1.36625289507181 -1.36686344552321 -0.536694160-0.5 -3.47105999631867 -3.84214736961781 -3.85166396113872 -0.966049489
0 NaN NaN NaN Inf
EJERCICIO 4
dxdt
+5 x=20
x(0)=2 en el intervalo [0,10]
Resolviendo para encontrar dydx
se obtiene:
dydx
=−5(x−4)
%COMPARACIÓN DE LOS TRES MÉTODOS (ECUACIONES DIFERENCIALES)function [xr xp1 xp2 xp3 tp1]=Tarea7Ej3h=0.05;ti=-1 %Condición Inicialtf=0x0=-1 %Condición Final%Eulerx=x0;i=1;for t=ti:h:tf x=x+h*f1(x,t); xp1(i)=x; tp1(i)=t; i=i+1;end%Euler Modificadox=x0;i=1;for t=ti:h:tf x_aux=x+h*f1(x,t); x=x+(h/2)*(f1(x,t)+f1(x_aux,t+h)); xp2(i)=x; tp2(i)=t; i=i+1;end%Rangex=x0;i=1;for t=ti:h:tf k1=h*f1(x,t) k2=h*f1(x+0.5*k1,t+0.5*h); k3=h*f1(x+0.5*k2,t+0.5*h); k4=h*f1(x+k3,t+h); x=x+(1/6)*(k1+2*k2+2*k3+k4); xp3(i)=x; tp3(i)=t; i=i+1;endtr=ti:h:tf;xr=-1*(exp(tr+1)/tr*tr).^-1; %Agregar la Solucionplot(tr,xr,'b');hold onplot(tp1,xp1,'k');plot(tp2,xp2,'r');plot(tp3,xp3,'g');legend('Analitica','Euler','Euler Modificado','Range 4to Orden')endfunction z=f1(x,t)z=x-t*x/t.^2;end
La solución de la Ecuación Diferencial es:
x=−2e5 t
+4
Con h=0.01
t Euler Euler Modificada Range Analítica0.1 2,86239981544708 2,84582579677820 2,84610034477739 3,6967346701436
81.5 3,99913444554848 3,99894433740829 3,99894777931439 3,9997234578149
32 3,99993339993413 3,99991325216971 3,99991362845474 3,9999773000351
23 4.00000000000000 3,99999941423206 3,99999941803295 3,9999998470488
44 4.00000000000000 3,99999999604458 3,99999999607874 3,9999999989694
25 4.00000000000000 3,99999999997329 3,99999999997358 3,9999999999930
610 4.00000000000000 4,00000000000000 4,00000000000000 4
Con h=0.05
t Euler Euler Modificada Range Analítica0.1 3,15625000000000 3,04632568359375 3,05523846973665 3,6967346701436
81.5 3,99973212686475 3,99905044322542 3,99913824704077 3,9997234578149
32 3,99998491512226 3,99999942293884 3,99992925591492 3,9999773000351
23 3,99999995216266 3,99999942293884 3,99999952323448 3,9999998470488
45 3,99999999999952 3,99999999997030 3,99999999997835 3,9999999999930
610 4,00000000000000 4,00000000000000 4,00000000000000 4
EJERCICIO 5
y '+(tanx ) y=cos2 xy(0)=-1 en el intervalo [0,20]
%COMPARACIÓN DE LOS TRES MÉTODOS (ECUACIONES DIFERENCIALES)function [xr xp1 xp2 xp3 tp1]=Tarea7Ej4h=0.05;ti=0 %Condición Inicialtf=10x0=2 %Condición Final%Eulerx=x0;i=1;for t=ti:h:tf x=x+h*f1(x,t); xp1(i)=x; tp1(i)=t; i=i+1;end%Euler Modificadox=x0;i=1;for t=ti:h:tf x_aux=x+h*f1(x,t); x=x+(h/2)*(f1(x,t)+f1(x_aux,t+h)); xp2(i)=x; tp2(i)=t; i=i+1;end%Rangex=x0;i=1;for t=ti:h:tf k1=h*f1(x,t) k2=h*f1(x+0.5*k1,t+0.5*h); k3=h*f1(x+0.5*k2,t+0.5*h); k4=h*f1(x+k3,t+h); x=x+(1/6)*(k1+2*k2+2*k3+k4); xp3(i)=x; tp3(i)=t; i=i+1;endtr=ti:h:tf;xr=((-2)*((exp(5*tr)))).^-1+4; %Agregar la Solución de la Ecuaciónplot(tr,xr,'b');hold onplot(tp1,xp1,'k');plot(tp2,xp2,'r');plot(tp3,xp3,'g');legend('Analitica','Euler','Euler Modificado','Range 4to Orden')endfunction z=f1(x,t)z=-5*(x-4);end
Resolviendo para encontrar dydx
se obtiene:
dydx
=cos (x)sec ( x )∗y
La solución de la Ecuación Diferencial es:y=cos ( x )∗(sin ( x )−1)
Con h=0.01t Euler Euler Modificada Range Analítica
0.1 -1.11524406587010 -1.11578008619992 -1.11578412153690 -0.0355254815737
110 -184.346264626024 -187.760415963514 -187.77246570030620 -25694.0426097533 -26576.7900886176 -26579.7936076585
Con h=0.05
t Euler Euler Modificada Range Analítica0.1 -1.15693795270928 -1.16039399139194 -1.16053377081663 -
0.03552548157371
10 -176.342579835929 -192.605503563855 -192.92104189628120 -22661.7570600621 -26657.8109531612 -26734.2748052157
%COMPARACIÓN DE LOS TRES MÉTODOS (ECUACIONES DIFERENCIALES)function [xr xp1 xp2 xp3 tp1]=Tarea7Ej4h=0.01;ti=0 %Condición Inicialtf=20x0=-1 %Condición Final%Eulerx=x0;i=1;for t=ti:h:tfx=x+h*f1(x,t);xp1(i)=x;tp1(i)=t;i=i+1;end%Euler Modificadox=x0;i=1;for t=ti:h:tfx_aux=x+h*f1(x,t);x=x+(h/2)*(f1(x,t)+f1(x_aux,t+h));xp2(i)=x;tp2(i)=t;i=i+1;end%Rangex=x0;i=1;for t=ti:h:tfk1=h*f1(x,t)k2=h*f1(x+0.5*k1,t+0.5*h);k3=h*f1(x+0.5*k2,t+0.5*h);k4=h*f1(x+k3,t+h);x=x+(1/6)*(k1+2*k2+2*k3+k4);xp3(i)=x;tp3(i)=t;i=i+1;endtr=ti:h:tf;xr=cos(t)*(sin(t)-1); %Agregar la Solucionplot(tr,xr,'b');hold onplot(tp1,xp1,'k');plot(tp2,xp2,'r');plot(tp3,xp3,'g');legend('Analitica','Euler','Euler Modificado','Range 4to Orden')endfunction z=f1(x,t)z=cos(t)/(1/cos(t))*x;end