Single step methods Runge-Kuta方法:1905(德国) S,=f(tn, yn) ,mmmmmmmmm 若f不依赖y则为 h-2h2 S2=∫(tn+,yn+S1 Simpson公式 h S3=∫(tn+,yn+S 如何确定h? S4=f(t,+h,y,+hs3) yn+(S1+2S2+2s3+S4) =t th
t t h s s s s h y y s f t h y hs s h y h s f t s h y h s f t s f t y n n n n n n n n n n n n 1 1 1 2 3 4 4 3 3 2 2 1 1 ( 2 2 ) 6 ( , ) ) 2 , 2 ( ) 2 , 2 ( ( , ) Single Step Methods Runge-Kutta方法:1905(德国) 若f不依赖y,则为 simpson公式 如何确定h?
Single Step Methods 计算方法: s1=f(n+ah,yn+b∑B,S),t=1…,k y 两组方法 如果误差小于指定的精度,进行下一步,否则,缩小步 长 Matlab: ode23 ode45
Single Step Methods 1 1 , ( , ), 1,..., i j i n i n i j j s f t h y h s i k k i n n i i y y h s 1 1 k i n i i e h s 1 两组方法 1 计算方法: 如果误差小于指定的精度,进行下一步,否则,缩小步 长。 Matlab: ode23,ode45
BS23 algorithm ode23: Bogacki, Shampine(1989)和 Shampine(1994),”23表 示用两算法:一个2阶,一个3阶 f(tn, yn) MATLAB s2=f(t,+a,ym+s, ode23tx m 3 S3=f(t, +h,y,+hs2) Bogacki. P and lF t +h Shampine, A3(2) pair of Runge-Kutta +-(2S,+3s,+4s3 formulas " Appl Math Letters vol S4=f(tnl,yn+ 1989,pp1-9 h n+1 72 (-5s+62+8s3-94)
BS23 algorithm ode23: Bogacki,Shampine(1989)和Shampine(1994), ”23”表 示用两算法:一个2阶,一个3阶 ( 5 6 8 9 ) 72 ( , ) (2 3 4 ) 9 ) 4 3 , 4 3 ( ) 2 , 2 ( ( , ) 1 1 2 3 4 4 1 1 1 1 2 3 1 3 2 2 1 1 s s s s h e s f t y s s s h y y t t h s f t h y hs s h y h s f t s f t y n n n n n n n n n n n n n ode23tx.m Bogacki, P. and LF Shampine, "A 3(2) pair of Runge-Kutta formulas, " Appl. Math. Letters, Vol. 2, 1989, pp 1-9
Examples MATLAB 精确解 iode23tx(02[010],1) ode23tx(2*yy201011)2/(1+exp-2 F=inline(y(2); -y(DI,t,y,) ":i[ty]=ode23tx(F,[02*pi][10]) plot(y(;1)2y(:,2),-0”) ode23tx(F,[028pi]1:0]) aXIs([-1.21.2-1.21.2]) axis square opts=odesetcreltol, 1.e-4,abstol,, 1. e-6,outputfcn', @odephas2)
Examples ode23tx(‘0’ ,[0 10],1) ode23tx(‘2*y-y^2’ ,[0 10],1) 2/(1+exp(-2*t)) 1 精确解 F=inline('[y(2);-y(1)]' , 't' , 'y') ode23tx(F,[0 2*pi],[1;0]) [t,y]=ode23tx(F,[0 2*pi],[1;0]) plot(y(:,1),y(:,2), ’-o’) axis([-1.2 1.2 –1.2 1.2]) axis square opts=odeset(‘reltol’ ,1.e-4, ’abstol’ ,1.e-6, ’outputfcn’ ,@odephas2)