10.1) Resuelva los siguientes problemas en 0 ≤ t ≤ 5 utilizando el método de Euler
hacia adelante con h=0.01 en Matlab. Evalúe los errores comparando con las soluciones que se muestran más adelante.
%Ecuaciones Diferenciales por el método de Euler
f=input('\nIngrese la ecuación diferencial de la forma (dy/dx):','s'); t0=input('\nIngrese el primer punto t0:'); t1=input('\nIngrese el segundo punto t1:'); y0=input('\nIngrese la condición inicial y(0):'); n=input('\nIngrese el número de pasos n:'); h=(t1-t0)/n; ts=t0:h:t1; y1=y0; fprintf('\n''it t0 t1 y1'); for i=1:n; it=i-1; t0=ts(i); t=t0; t1=ts(i+1); y=y0; y1=y0+h*eval(f); fprintf('\n%2.0f%10.6f%10.6f%10.6f\n',it,t0,t1,y1); y0=y1; end fprintf('\nEl punto aproximado y(t1) es=%10.6f\n',y1) a- y’ + ty = 1 , y(0)=1 Ingrese la ecuación diferencial de la forma (dy/dx): 1-t*y Ingrese el primer punto t0:0 Ingrese el segundo punto t1:5 Ingrese la condición inicial y (0):1 Ingrese el número de pasos n: 500 El punto aproximado y (t1) es= 0.209221 b- y ’ + 3y = e-t , y(0)=1 Ingrese la ecuación diferencial de la forma (dy/dx): -3*y+exp(-t) Ingrese el primer punto t0:0 Ingrese el segundo punto t1:5 Ingrese la condición inicial y (0):1 Ingrese el número de pasos n: 500 El punto aproximado y (t1) es= 0.003361 c- y ’ = (t2 – y) , y(0)=0.5 Ingrese la ecuación diferencial de la forma (dy/dx): t^2-y Ingrese el primer punto t0:0 Ingrese el segundo punto t1:5 Ingrese la condición inicial y (0):0.5 Ingrese el número de pasos n: 500 El punto aproximado y (t1) es= 16.980210 d- y ’ + y l y l = 0, y(0)=1 Ingrese la ecuación diferencial de la forma (dy/dx):-y*abs(y) Ingrese el primer punto t0:0 Ingrese el segundo punto t1:5 Ingrese la condición inicial y (0):1 Ingrese el número de pasos n: 500 El punto aproximado y(t1) es= 0.166168 e- y ’ + y l y l1/2 = sen (t), y(0)=1 Ingrese la ecuación diferencial de la forma (dy/dx):sin(t)-[abs(y)]^0.5 Ingrese el primer punto t0:0 Ingrese el segundo punto t1:5 Ingrese la condición inicial y (0):1 Ingrese el número de pasos n: 500 El punto aproximado y (t1) es= -2.233892 10.3) Resuelva los siguientes problemas en 0 ≤ t ≤ 5 utilizando el método de Euler hacia adelante con h=0.1 y h=0.01 (Escriba su propio programa en Matlab). Evalúe los errores con las soluciones exactas que se muestran más adelante.
a) y’’ + 8y = 0, y(0) = 1, y’(0)=0
t=input('to='); n=input('n='); y6=y5+(h*(ye5))
yo=input('yo::'); h=input('h='); end dy=¡nput('Ingrese la ecuaa'óndy/dx='); end z=dy; if 0<=t<=5 Untitled3 Ingrese to=0 Ingrese n=0 Ingrese for t=0 yo=l zl=l-t*yo; Ingrese h^O.Ol ylryo+(h*(yel)) Ingrese la ecuación dy/dx=l-(t.*yo) end for tl=n+l zl=l-tl*yl; z:yl+(n*(yel)) end yl = for t2=tl+l 1.0100 y2 = z2=l-t2*y2: z=y2+(h*(ye2)) 1.0099 end y3 = for t3=t2+l z3=l-t3*y3; z=y3+(h*(ye3)) end -0.0036 y4 = for t4-t3+l z4=l-t4*y4; -0.0046y5 = y5=y4+(h*(ye4)) -0.0048 yó = end -0.0050 for t5=t4+l z5=l-t5*y5;
b) y'’ – 0.01(y’ 2) + 2y = 0, y(0) = 0, for t5=t4+l z5=exp(-t5)-3*y5;
y’(0)=1 y6=y5+(h*(ye5)) t=input('to='); end end n=input('n='); » Untitled3 Ingrese io-0 Ingrese r\-0 Ingrese yo=input('yo=')<' h=input('h='); yo=l Ingrese h=0.01 dy=input('Ingrese la ecuación dy/dx Ingrese la ecuación dy/dx= 0.01(y’ 2) - 2y z=dy; -0.8468 if 0<=t<=5 y3 = for t=0 -0.8729 y4 = zl=exp(-t)-3*yo; yl=yo+(h*(yel)) -0.8997 y5 = end -0.9270 y6 = for tl=n+l zl=exp(-tl)-3*yl; y2=yl+(h*(yel)) -0.9583 end for t2=tl+l z2-exp(-t2)-3*y2; y3=y2+(h*(ye2)) end for t3=t2+l z3=exp(-t3)-3*y3; y4=y3+(h*(ye3)) end for t4=t3+l ye4=exp(-t4)-3*y4; y5=y4+(h*(ye4)) end c) y’' + 2ty’ + ty = 0, y(0) = 1, y’(0)=0 d) (e’ + y) y’’ = t, y(0) = 1, y’(0)=0
yo=input('yo='); h=input('h='); yo=input('yo-).' h=input('h='); dy=input('Ingrese la ecuación dy/dx=') dy=input('Ingrese la ecuaciondy/dx='); ye=dy; z=dy; if 0<=t<=5 if 0<=t<=5 for t=0 f or t=0 z0r((t.^2)-yo); z0=(-yo*(abs(yo))); yl=yo+(h*(ye0)) yl=yo+(h*(ye0)) end end for tl=n+l for tl=n+l zl=((tl.^2)-yl); yel=(-yl*(abs(yl))); y2=yl+(h*(yel)) y2:yl+(h*(yel)) end end for t2=tl+l z2=(-y2*(abs(y2))); for t2=tl+l Z2=((t2."2)-y2); y3ry2+(h*(ye2)) y3=y2+(h*(ye2)) end end for t3=t2+l z3=(-y3*(abs(y3))); for t3=t2+l z3=((t3.*2)-y3); y4=y3+(h*(ye3)) y4=y3+(h*(ye3)) end end for t4=t3+l for t4=t3+l z4=((t4."2)-y4); y5=y4+(h*(ye4)) z4r(-y4*(abs(y4))); y5=y4+(h*(ye4)) end end for t5=t4+l for t5=t4+l z5=(-y5*(abs(y5))); z5=((t5.*2)-y5): y6=y5+(h*(ye5)) y6=y5+(h*(ye5)) end end end cnd Untitled3 Ingrese to=0 Ingrese n=0 Ingrese Untitled3 Ingrese to=0 Ingrese r\-0 Ingrese yo-1 Ingrese h=0.01 yo=0.5 Ingrese h=0.01 Ingrese la ecuación dy/dx= t / (e’ + y) Ingrese la ecuación dy/dx=- 2ty’ - ty yl = yl = 0.9900 y2z 0.4950 y2 = 0.9802 0.5000 y3 = y3 = 1.9706 y4 = 0.4350 y4 = 2.3412 y5 = 0.3197 y5 = 2.9519 y6 = 0.2735 y6 = 3.2329 0.1038
(AntiDemidovich_ Matemática Superior_ Problemas Resueltos) A.K. Boiarchuk, G.P. Golovach _ traducido del ruso bajo la dirección de Viktoria O. Malishenko y Guillermo Peña Feria _ revisión científi