Lecture_26_E7_L26_ODE3_07 - 1 E7: INTRODUCTION TO COMPUTER...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
E7 L26 1 E7: INTRODUCTION TO COMPUTER E7: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND PROGRAMMING FOR SCIENTISTS AND ENGINEERS ENGINEERS Lecture Outline 1. Numerical integration of ODEs: Euler (review) Modified Euler Runge-Kutta (used in ode45) 1. More ODE examples Inverted pendulum
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E7 L26 2 Review of Ordinary Differential Equations (ODEs) Review of Ordinary Differential Equations (ODEs) Many problems in science and engineering lead to Ordinary Differential Equations ( ODE s) of the form ( ) ( , ) dy t f t y dt = where: t is the independent scalar variable (often time) y is the dependent variable, which can be a vector f(t,y)  is a known function of its arguments
Background image of page 2
E7 L26 3 Solution of ODEs (Initial Value Problem) Solution of ODEs (Initial Value Problem) Given the ODE ( ) ( , ) dy t f t y dt = and an initial condition 0 0 ( ) y t y = find the function ( ) y t which satisfies: 0 0 ( ) y t y = ( ) ( , ( )) dy t f t y t dt = (slight abuse of notation) 0 t t for
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E7 L26 4 Consider the ODE and the initial condition We want to obtain the estimates where and is the integration step size integration step size . Numerical integration of ODEs Numerical integration of ODEs ( ) ( , ) y t f t y = & 0 0 ( ) y t y = ( ) E k y t 0 k t t k h = + ⋅ h 0,1,2,. ... k =
Background image of page 4
E7 L26 5 Numerical integration of ODEs Numerical integration of ODEs Today we will review Euler’s method Approximates a Taylor expansion up to its first order and describe: Modified Euler’s method (predictor-corrector) Approximates a Taylor expansion up to its second order Rungue-Kutta method (used in ode45, ode23) Approximates a Taylor expansion up to its fourth order
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E7 L25 6 Approximating Approximating y(to+h)     - Taylor’s series expansion - Taylor’s series expansion 0 0 ( ) ( ) y t y t h + & 2 0 1 ( ) 2 y t h + && Euler (n=1) modified Euler (n=2) h h 0 ( ) y t h +
Background image of page 6
[3] 3 [4] 4 0 0 1 1 ( ) ( ) 3! 4! y t h y t h + + E7 L25 7 4 4 th th order Taylor’s series expansion order Taylor’s series expansion Runge-Kutta(n=4) h h 2 0 0 0 0 1 ( ) ( ) ( ) ( ) 2 y t h y t y t h y t h + + ⋅ + & && h
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E7 L26 8 can be approximated approximated using the first order term of the Taylor series expansion, for a small enough Euler’s method Euler’s method 1 0 ( ) ( ) y t y t h = + 1 0 0 ( ) ( ) ( ) y t y t y t h + & and we use the ODE to obtain h ( ) ( , ) y t f t y = & 1 0 0 0 ( ) ( ) ( , ( )) y t y t f t y t h +
Background image of page 8
E7 L26 9 Notice that we are using the superscript E to denote the approximate solution of the ODE Euler’s method Euler’s method The algorithm is repeated using the estimates 1 0 0 0 ( ) ( ) ( , ( )) E y t y t f t y t h = + 1 ( ) ( ) ( , ( )) E E E k k k k y t y t f t y t h + = + 1 k k t t h + = + ( ) E k y t
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Graphical explanation of Euler’s method Graphical explanation of Euler’s method E7 L26 10 t 0 t 1 t 2 t 0 ( ) y t h h ( ) y t 0 0 ( , ( )) f t y t h ( ) ( , ) y t f t y = & 1 ( ) E y t 1 ( ) y t ( ) y t
Background image of page 10
E7 L26 11 ( ) ( , ) y t f t y = & 1 ( ) y t t 0 t 1 t 2 t 0 ( ) y t h h 1 1 ( , ( )) E f t y t h 1 ( ) E y t 2 ( ) E y t Graphical explanation of Euler’s method Graphical explanation of Euler’s method ( ) y t
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
E7 L25 12 Euler integration on pendulum example ( Palm 8.6–1) function ydot = ydot_pend(t,y) global mgl % mgl = -g/L is a global ydot = [ y(2); mgl * sin(y(1))]; L g θ 2 1 sin( ) g y y L = - & 1 2 y y = & 1 y θ = 2 y = &
Background image of page 12
E7 L25 13 global mgl, mgl = -9.81
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 47

Lecture_26_E7_L26_ODE3_07 - 1 E7: INTRODUCTION TO COMPUTER...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online