Docsity

Numerical Solutions to Ordinary Differential Equations (ODEs) using Euler's Method - Prof., Study notes of Computer Science

Partial preview of the text

Download Numerical Solutions to Ordinary Differential Equations (ODEs) using Euler's Method - Prof. and more Study notes Computer Science in PDF only on Docsity!

Lecture 27

Numerical ODEs

L. Olson

Department of Computer Science University of Illinois at Urbana-Champaign

April 24, 2006

Wiki of the day

Highlight some interesting progress:

Caching in Matlab

interesting as it highlights an essential component of our linear algebra section: level 1, 2, and 3 BLAS routines dot products, matrix-vector multiplies, matrix-matrix multiplies some intriguing matlab tests that you can use on your own machine to test caching +5 extra wiki points

ODEs: an example

dy dt

2 y How to solve? ...lots of ways. Try separation of variables: 2 ydy = −dt

⇒

2 ydy = −

dt

⇒y^2 = −t + c ⇒y =

c − t

Example

Equation Initial Value Solution dy dt =^ y^ +^1 y(^0 ) =^0 y^ =^ e

t (^) − 1 dy dt =^6 t^ −^1 y(^1 ) =^6 y^ =^3 t

(^2) − t + 4 dy dt =^

t x+ 1 y(^0 ) =^0 y^ =^

t^2 + 1 − 1

ODEs

ODEs arise in every field of science and in many other disciplines such as economics, finance, etc. problem: ODEs are not always easily solved analytically:

dy dt

= f (y, t)

y(t 0 ) = y 0

yields y(t) = y 0 +

∫ (^) t

t 0

f (s, y) ds

what to do?

Goals in ODEs

Big Methods: Euler’s Method: Use the first term of a Taylor Series expansion Midpoint Method: improve on Euler Runge-Kutta Methods: large improvement Big Ideas: In each of the three, we improve accuracy...at a cost What is the accuracy and how is it measured? How do we implement these routines? What’s used in practice? (RK variants → ode23 and ode45 in Matlab)

Today: Euler’s Method

Numerical ODEs: take small steps in time, making an approximation to the solution along the way let t be given by tj = t 0 + jh tj are the disrete points, h is the stepsize we want approximations to y(t) at tj: yj error: ej = yj − y(tj)

Euler

Then the solution at the next point (t 1 ) becomes

y(t 1 ) ≈ y(t 0 ) + (t 1 − t 0 )f (t 0 , y 0 )

or y 1 = y 0 + hf (t 0 , y 0 ) This is Euler’s Method:

Euler’s Method

yj = yj− 1 + hf (tj− 1 , yj− 1 )

Euler

Example

dy dt

= t − 2 y, y( 0 ) = 1

Exact solution: y = ( 1 / 4 )( 2 t − 1 + 5 e−^2 t)

(demoEuler.m)(odeEuler.m)(rhs1.m)

Euler: Error

we’re concerned with discretization error: related to truncation error what is the error from step-to-step? local LDE what is the error over the interval? global GDE