• Notes
• 24

This preview shows page 1 - 7 out of 24 pages.

M ATLAB solvers Adaptivity Stiffness Adaptive Methods and Stiff Systems Dhavide Aruliah UOIT MATH 2070U c D. Aruliah (UOIT) Adaptive Methods and Stiff Systems MATH 2070U 1 / 26
M ATLAB solvers Adaptivity Stiffness Adaptive Methods and Stiff Systems 1 M ATLAB IVP solvers 2 Adaptive IVP solvers 3 Stiffness c D. Aruliah (UOIT) Adaptive Methods and Stiff Systems MATH 2070U 2 / 26
M ATLAB solvers Adaptivity Stiffness Reminder: IVP systems Generic first-order IVP: ( y 0 = f ( t , y ) y ( t 0 ) = y 0 I t R : independent variable (time) I y = y ( t ) R m × 1 : vector of m dependent variables I f ( t , y ) : vector field dependent on values of t and y E.g., t 0 : = 0, f ( t , y ) : = ( y 2 , sin ( 3 t ) - 4 y 1 ) T , & y 0 : = ( 1.5, 0 ) T yields ( y 0 1 = y 2 , y 1 ( 0 ) = 1.5, y 0 2 = sin ( 3 t ) - 4 y 1 , y 2 ( 0 ) = 0 Any high-order ODE can be converted to a first-order system c D. Aruliah (UOIT) Adaptive Methods and Stiff Systems MATH 2070U 4 / 26
M ATLAB solvers Adaptivity Stiffness Reminder: Naive solvers for IVPs Traditional DE course focuses on analytic methods , but we need to solve most problems using numerical methods (approximations) We developed euler.m , rk2.m , rk4.m to solve 1 st -order IVPs To encode problem to solve in M ATLAB using, e.g., RK4: [t,y] = rk4(f,tspan,y0,N) Input: f , tspan , y0 I function handle f : implementation of function f I 2-vector tspan : interval of integration [ t 0 , t final ] I n -vector y0 : initial condition I positive integer N : number of time-steps Output: t , y I N -vector t : mesh of time values I N × m matrix y : components of numerical solution along columns c D. Aruliah (UOIT) Adaptive Methods and Stiff Systems MATH 2070U 5 / 26
M ATLAB solvers Adaptivity Stiffness M ATLAB ’s ODE suite M ATLAB IVP solvers: ode23 , ode45 , ode15s , ode23s , etc. (we say “ODE four five” rather than “ODE forty-five”, etc.) Two numbers refer to order of accuracy of embedded pair Adaptive time-stepping : error estimated by embedded pair Not mandatory to specify N (number of time-steps) Most IVP solvers based on Runge-Kutta methods [some use multistep methods, predictor-corrector methods, etc.] c D. Aruliah (UOIT) Adaptive Methods and Stiff Systems MATH 2070U 6 / 26
M ATLAB solvers Adaptivity Stiffness M ATLAB IVP solvers Numerical solution of IVP system ( y 0 = f ( t , y ) , y ( t 0 ) = y 0 with M ATLAB : Call ode23 (or ode45 , etc.) [t,y] = ode23( f, tspan, y0 ); Input: f , tspan , y0 I function handle f : implementation of function f I 2-vector tspan : interval of integration I n -vector y0 : initial condition Output: t , y I K -vector t : mesh of time values I K × m matrix y
• • • 