Euler Solution(h=0. 1)of y'=-5y, y(o)=1 y"=-5.0y,y(0)=1 0= computed solution 04 -0.05 0.0 0.15 0.3 0.3 Showtrunc m
-0.1 -0.05 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 y' = -5.0y, y(0) = 1 * = exact solution o = computed solution Euler Solution (h=0.1) of y'=-5y, y(0) = 1 Showtrunc.m
h=(t max t0)/ h LTEM cm)-y∑E=M2N=m oM.h max M,≤tol 2N n=ceil(((tmax-tO)2*M2)/(2*tol)+1
h = (tmax −t 0 )/ N 2 | | 2 2 h LTEn M M h h t t y t y LTE M N N n N n 2 1 max 0 2 max 2 2 2 | ( ) | | | = − − = = M tol N t t − 2 2 max 0 2 ( ) n = ceil(((tmax-t0)^2*M2)/(2*tol))+1;
Fixed h Euler frror for v'=-V. v(0)=1 tol=01 vals,ovals FixedEuler(fl, 1, 0, 5, 1, tol) Showfixedeuler m 15 ol=0010.n=1251 be taken in regions where the solution is smoo er step Sizes can It is better to determine h adaptively so that long
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 0 2 4 6 8 x 10-4 Fixed h Euler Error for y'=-y, y(0) = 1 tol = 0.010, n = 1251 Showfixedeuler.m tol=.01; [tvals,yvals] = FixedEuler('f1',1,0,5,1,tol); It is better to determine h adaptively so that longer step sizes can be taken in regions where the solution is smooth
Euler in 3-Digit Arithmetic 0.045 . o4 Note that the error gets worse as h get smaller because the step size are in the neighborhood of 0.035 unit roundoff. 0.03 0.025 0.02 h=1/180 0.015 h=1/160 0.01 0.005 h=1/140 0.2 0.3 04 0.6 0.7 0.8 0.9
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0.04 0.045 0.05 Euler in 3-Digit Arithmetic h = 1/140 h = 1/160 h = 1/180 Note that the error gets worse as h get smaller because the step size are in the neighborhood of unit roundoff
Stability y(t)=-10y(t) yn+1=(1-10h)yn 1-10h1→h<1/5
Stability y'(t) = −10y(t) n n y (1 10h)y +1 = − |1−10h |1 h 1/5