20 - Numerical Differentiation IVPs for ODEs Discretisation...

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

View Full Document Right Arrow Icon
Numerical Differentiation IVPs for ODEs Discretisation & one-step methods Initial-Value Problems for Ordinary Differential Equations Dhavide Aruliah UOIT MATH 2070U c ± D. Aruliah (UOIT) MATH 2070U 1 / 32
Background image of page 1

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

View Full DocumentRight Arrow Icon
Numerical Differentiation IVPs for ODEs Discretisation & one-step methods Initial-Value Problems for Ordinary Differential Equations 1 Numerical Differentiation 2 Initial-value problems for ordinary differential equations Differential equations and initial-value problems Solutions of DEs and IVPS 3 Discretisation of differential equations: one-step methods Euler’s method Accuracy and Stability Modifications of Euler’s method c ± D. Aruliah (UOIT) MATH 2070U 2 / 32
Background image of page 2
Numerical Differentiation IVPs for ODEs Discretisation & one-step methods Implementation in M ATLAB with diff diff computes differences of successive elements in a vector For nonuniform grids, use in conjunction with vectorised operator ./ for convenience e.g., following implements forward differences ( f ( x k + 1 ) - f ( x k ) / ( x k + 1 - x k ) on nonuniform grid x = [1,1.25,1.3,1.5,1.7,1.9,2.0]; % nonuniform grid in x y1 = 5*x-3; % Compute first function on grid x y2 = 3*x.^2-4*x+2; % Compute second function on grid x dy1dx_f = diff(y1)./diff(x); % Forward differences dy2dx_f = diff(y2)./diff(x); % Forward differences c ± D. Aruliah (UOIT) MATH 2070U 4 / 32
Background image of page 3

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

View Full DocumentRight Arrow Icon
Numerical Differentiation IVPs for ODEs Discretisation & one-step methods Example A car laps a race track in 84 s. The speed of the car (in ft/s) is determined at 6 second intervals starting from the beginning of the lap using a radar gun. time 0 6 12 18 24 30 36 42 speed 124 134 148 156 147 133 121 109 time 48 54 60 66 72 78 84 speed 99 85 78 89 104 116 123 What is the acceleration of the car at any given time? Let v ( t ) denote speed at time t , so acceleration is v 0 ( t ) Here, h = 6 s is time-step between measurements Use v 0 ( t ) ( δ v )( t ) = ( v ( t + h ) - v ( t - h )) / ( 2 h ) for t = 6, 12, . . . , 78 Use v 0 ( 0 ) ( δ v )( 0 ) = ( v ( h ) - v ( 0 )) / h at t = 0 Use v 0 ( 84 ) ( δ v )( 84 ) = ( v ( 84 ) - v ( 84 - h )) / h at t = 84 c ± D. Aruliah (UOIT) MATH 2070U 5 / 32
Background image of page 4
Numerical Differentiation IVPs for ODEs Discretisation & one-step methods Example (cont.) v 0 ( 0 ) v ( 6 ) - v ( 0 ) 6 v 0 ( 6 ) v ( 12 ) - v ( 0 ) 2 · 6 ··· v 0 ( 84 ) v ( 84 ) - v ( 78 ) 6 = 134 - 124 6 = 148 - 124 12 = 123 - 116 6 = 1.666667 = 2.000000 = 1.166667 t 0 6 12 18 24 30 36 42 v ( t ) 124 134 148 156 147 133 121 109 v 0 ( t ) 1.667 2.00 1.833 - 0.0833 - 1.917 - 2.167 - 2.00 - 1.833 t 48 54 60 66 72 78 84 v ( t ) 99 85 78 89 104 116 123 v 0 ( t ) - 2.00 - 1.75 0.3333 2.167 2.25 1.583 1.167 v=[124,134,148,156,147,133,121,109,99,85,78,89,104,116,123]; h=6; % Size of time-step/mesh-spacing vprime=gradient(v,h) % Need h to set scale properly c ± D. Aruliah (UOIT) MATH 2070U 6 / 32
Background image of page 5

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

View Full DocumentRight Arrow Icon
Numerical Differentiation IVPs for ODEs Discretisation & one-step methods M ATLAB routines for differentiation diff Differences of adjacent elements of vector gradient Gradient of scalar field using differences del2 Laplacian of scalar field divergence Divergence of vector field curl Curl of vector field polyder Analytic derivative of polynomial diff differences columns of 2D arrays MATLAB gradient command computes gradient field Numerical differences used to approximate derivatives Centred differences in interior of 2D array Forward/backward differences at boundary of 2D array c ± D. Aruliah (UOIT) MATH 2070U 7 / 32
Background image of page 6
Numerical Differentiation IVPs for ODEs Discretisation & one-step methods Using M ATLAB ’s gradient hx = 0.2; hy = 0.1; % Spacing in x & y directions
Background image of page 7

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

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

This note was uploaded on 06/20/2011 for the course MATH 2070 taught by Professor Aruliahdhavidhe during the Winter '10 term at UOIT.

Page1 / 28

20 - Numerical Differentiation IVPs for ODEs Discretisation...

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

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