31
[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical & Mechanical Engineer [email protected] Engr/Math/Physics 25 Chp9: ODE’s Numerical Solns

ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

Embed Size (px)

DESCRIPTION

ENGR-25_Lec-21_Integ_Diff.ppt 3 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Differential Equations  Ordinary Diff Eqn  Partial Diff Eqn  PDE’s Not Covered in ENGR25 Discussed in More Detail in ENGR45  Examining the ODE, Note that it: is LINEAR → y, dy/dt, d 2 y/dt 2 all raised to Power of 1 2 nd ORDER → Highest Derivative is 2 is NONhomogenous → RHS  0; –i.e., y(t) has a FORCING Fcn f(t) has CONSTANT Coefficients

Citation preview

Page 1: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt1

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Bruce Mayer, PELicensed Electrical & Mechanical Engineer

[email protected]

Engr/Math/Physics 25

Chp9: ODE’sNumerical

Solns

Page 2: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt2

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Learning Goals List Characteristics of Linear,

MultiOrder, NonHomgeneous Ordinary Differential Equations (ODEs)

Solve ANALYTICALLLY, Linear, 2nd Order, NonHomogeneous, Constant Coefficient ODEs

Use MATLAB to determine Numerical Solutions to Ordinary Differential Equations (ODEs)

Page 3: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt3

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Differential Equations Ordinary Diff Eqn )(212

2

tftyatdtdyat

dtyd

Partial Diff Eqn tx

xytxybtx

tybtx

ty ,,,, 212

2

PDE’s Not Covered in ENGR25• Discussed in More Detail in ENGR45

Examining the ODE, Note that it: • is LINEAR → y, dy/dt, d2y/dt2 all raised to Power of 1• 2nd ORDER → Highest Derivative is 2• is NONhomogenous → RHS 0;

– i.e., y(t) has a FORCING Fcn f(t)• has CONSTANT Coefficients

Page 4: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt4

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Numerical ODE Solution Today we’ll do some

MTH25 We’ll “look under the

hood” of NUMERICAL Solutions to ODE’s

The BASIC Game-Plan for even Sophisticated Solvers:• Given a STARTING

POINT, y(0)• Use ODE to find

dy/dt at t=0• ESTIMATE y1 as

001

tdt

dytyy

Page 5: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt5

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Numerical Solution - 1 Notation Exact Numerical

Method (impossible to achieve) by Forward Steps

tntn

)( nn tyy

),( nnn ytff

Number Step n

Length Step Time t

),( ytfdtdy

Now Consider

yn+1

tn

yn

tn+1

tt

Page 6: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt6

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Numerical Solution - 2 The diagram at Left shows

that the relationship between yn, yn+1 and the CHORD slope

yn+1

tn

yn

tn+1

tt

slope chord 1

tyy nn

The problem with this formula is we canNOT calculate the chord slope exactly • We Know Only Δt & yn, but

NOT the NEXT Step yn+1

The AnalystChooses Δt

ChordSlope

Tangent Slope

Page 7: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt7

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Numerical Solution -3 However, we can

calculate the TANGENT slope at any point FROM the differential equation itself

The Basic Concept for all numerical methods for solving ODE’s is to use the TANGENT slope, available from the R.H.S. of the ODE, to approximate the chord slope

Recognize dy/dt as the Tangent Slope

),( nntt

n ytfdtdym

n

),( slopetangent ytf nnt

nn ytfdtdy

tyy

n

,1

Page 8: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt8

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Euler Method – 1st Order Solve 1st Order

ODE with I.C. ReArranging

Use: [Chord Slope] [Tangent Slope at start of time step]

),( ytfdtdy

by )0( nnn ftyy 1

Then Start the “Forward March” with Initial Conditions

byt 00 0 nnt

nn ytfdtdy

tyy

n

,1

or1 nt

n ydtdyty

n

Page 9: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt9

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Euler Example Consider 1st

Order ODE with I.C.

Use The Euler Forward-Step Reln

See Next Slide for the 1st Nine Steps For Δt = 0.1

1 ydtdy

0)0( y

)1(1 nnn ytyy

ntn

nnn

dtdyty

ftyy

1

But from ODE

So In This Example:

1 nt

ydtdy

n

Page 10: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt10

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Euler Exmpl Calcn tn yn fn= – yn+1 yn+1= yn+t fn

0 0 0.000 1.000 0.100

1 0.1 0.100 0.900 0.1902 0.2 0.190 0.810 0.271

3 0.3 0.271 0.729 0.344

4 0.4 0.344 0.656 0.410

5 0.5 0.410 0.590 0.469

6 0.6 0.469 0.531 0.522

7 0.7 0.522 0.478 0.570

8 0.8 0.570 0.430 0.613

9 0.9 0.613 0.387 0.651

1.01 tydtdy

Plot

Slope

Page 11: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt11

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Euler vs Analytical

0

0.2

0.4

0.6

0.8

0

0.25 0.5

0.75 1

1.25

t

Exact

Numerical

y

tey 1

The Analytical Solution

Page 12: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt12

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Analytical Soln Let u = −y+1 Then

001 tyydtdy

dudydydu

yu

10

1

Sub for y & dy in ODE

udtdu

Separate Variables

dtudu

Integrate Both Sides

dtudu

1

Recognize LHS as Natural Log

Ctu ln Raise “e” to the

power of both sidesCtu ee ln

Page 13: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt13

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Analytical Soln And

001 tyydtdy

Thus Soln u(t)tKeu

Sub u = 1−y

Now use IC

The Analytical Soln

ttCCt

u

Keeee

ue

ln

tKey 1

101 0

KKe

tey 11

tey 1

Page 14: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt14

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Predictor-Corrector - 1 Again Solve 1st

Order ODE with I.C.

Mathematically

This Time Let: Chord slope average of tangent slopes at start and END of time step

),( ytfdtdy

by )0(

BUT, we do NOT know yn+1 and it appears on the RHS...

),(),(5.0 111

nnnnnn ytfytf

tyy

Avg of the Tangent Slopes at (tn,yn) & (tn+1,yn+1)

Page 15: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt15

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Predictor-Corrector - 2 Use Two Steps to

estimate yn+1

First → PREDICT*

Use y* in the Avg Calc

Then Correct

nnn

nnnn

nnn

nn

ftyy

ytftyy

dtdytyy

yyy

1

1

1

1

,

*

11

111

5.0

,,5.0

nnnn

nnnnnn

fftyy

ytfytftyy

Then Start the “Forward March” with the Initial Conditions

Page 16: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt16

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Predictor-Corrector Example Solve ODE with

IC The Corrector step

1 ydtdy 0)0( y

11 5.0 nnnn fftyy

The next Step Eqn for dy/dt = f(t,y)= –y+1

115.0 *11 nnnn yytyy

Numerical Results on Next Slide

Page 17: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt17

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Predictor-Corrector Example

n

0 0 0.000 1.000 0.100 0.900 0.095

1 0.1 0.095 0.905 0.186 0.815 0.181

2 0.2 0.181 0.819 0.263 0.737 0.259

3 0.3 0.259 0.741 0.333 0.667 0.329

4 0.4 0.329 0.671 0.396 0.604 0.393

nt ny nf*

1ny*

1nf 1ny

1 ydtdyf 11 5.0 nnnn fftyy

Slope Slope

Page 18: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt18

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Predictor-Corrector

0

0.2

0.4

0.6

0.8

0

0.25 0.5

0.75

1

1.25

t

Mod. Euler

Exact

y

Greatly Improved Accuracy

Page 19: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt19

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

ODE Example: Euler Solution with

∆t = 0.25 The Solution Table

61.5ln9.32.4cos9.3 tydtdy

0 1 2 3 4 5 6 7 8 9 1022

24

26

28

30

32

34

36

38

t

y(t)

by E

uler

Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)

n t y dy/dt dely yn+1

0 0 37.0000 -1.7457 -0.4364 36.56361 0.25 36.5636 1.4027 0.3507 36.91432 0.5 36.9143 -1.3492 -0.3373 36.57693 0.75 36.5769 1.2410 0.3103 36.88724 1 36.8872 -1.2264 -0.3066 36.58065 1.25 36.5806 1.0448 0.2612 36.84186 1.5 36.8418 -0.7108 -0.1777 36.66417 1.75 36.6641 1.1868 0.2967 36.96088 2 36.9608 -2.5004 -0.6251 36.33579 2.25 36.3357 -2.6357 -0.6589 35.6768

10 2.5 35.6768 -1.6265 -0.4066 35.270111 2.75 35.2701 0.0722 0.0181 35.288212 3 35.2882 -0.2436 -0.0609 35.227313 3.25 35.2273 0.4430 0.1107 35.338014 3.5 35.3380 -1.1420 -0.2855 35.052615 3.75 35.0526 -0.0139 -0.0035 35.049116 4 35.0491 -0.1072 -0.0268 35.022317 4.25 35.0223 -0.5255 -0.1314 34.890918 4.5 34.8909 -2.6041 -0.6510 34.239919 4.75 34.2399 -1.1497 -0.2874 33.952420 5 33.9524 -3.0108 -0.7527 33.199721 5.25 33.1997 -3.0006 -0.7502 32.449622 5.5 32.4496 -3.0151 -0.7538 31.695823 5.75 31.6958 -2.9862 -0.7466 30.949224 6 30.9492 -3.0384 -0.7596 30.189725 6.25 30.1897 -2.9328 -0.7332 29.456426 6.5 29.4564 -3.1419 -0.7855 28.671027 6.75 28.6710 -2.6916 -0.6729 27.998128 7 27.9981 -3.5484 -0.8871 27.111029 7.25 27.1110 -1.7458 -0.4365 26.674530 7.5 26.6745 -2.8722 -0.7180 25.956531 7.75 25.9565 -2.4562 -0.6141 25.342432 8 25.3424 -0.4717 -0.1179 25.224533 8.25 25.2245 -2.2562 -0.5641 24.660434 8.5 24.6604 -0.0369 -0.0092 24.651235 8.75 24.6512 -0.0977 -0.0244 24.626836 9 24.6268 -0.2699 -0.0675 24.559337 9.25 24.5593 -1.0481 -0.2620 24.297338 9.5 24.2973 -3.9863 -0.9966 23.300739 9.75 23.3007 -0.9318 -0.2329 23.067840 10 23.0678 -1.0551 -0.2638 22.8040

Page 20: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt20

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Compare Euler vs. ODE45Euler Solution ODE45 Solution

0 1 2 3 4 5 6 7 8 9 1022

24

26

28

30

32

34

36

38

t

y(t)

by E

uler

Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)

0 1 2 3 4 5 6 7 8 9 1034.5

35

35.5

36

36.5

37

37.5

T by ODE45

Y b

y O

DE

45

Euler is Much LESS accurate

Page 21: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt21

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Compare Again with ∆t = 0.025Euler Solution ODE45 Solution

0 1 2 3 4 5 6 7 8 9 1034.5

35

35.5

36

36.5

37

37.5

T by ODE45

Y b

y O

DE

45

Smaller ∆T greatly improves Result0 1 2 3 4 5 6 7 8 9 10

35.8

36

36.2

36.4

36.6

36.8

37

37.2

t

y(t)

by E

uler

Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)

Page 22: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt22

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

MatLAB Code for Euler% Bruce Mayer, PE% ENGR25 * 04Jan11% file = Euler_ODE_Numerical_Example_1201.m%y0= 37;delt = 0.25;t= [0:delt:10]; n = length(t);yp(1) = y0; % vector/array indices MUST start at 1tp(1) = 0;for k = 1:(n-1) % fence-post adjustment to start at 0 dydt = 3.9*cos(4.2*yp(k))^2-log(5.1*tp(k)+6); dydtp(k) = dydt % keep track of tangent slope tp(k+1) = tp(k) + delt; dely = delt*dydt delyp(k) = dely yp(k+1) = yp(k) + dely;endplot(tp,yp, 'LineWidth', 3), grid, xlabel('t'),ylabel('y(t) by Euler'),... title('Euler Solution to dy/dt = 3.9cos(4.2y)-ln(5.1t+6)')

Page 23: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt23

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

MatLAB Command Window forODE45

>> dydtfcn = @(tf,yf) 3.9*(cos(4.2*yf))^2-log(5.1*tf+6);>> [T,Y] = ode45(dydtfcn,[0 10],[37]);>> plot(T,Y, 'LineWidth', 3), grid, xlabel('T by ODE45'), ylabel('Y by ODE45')

Page 24: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt24

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

All Done for Today

CarlRunge

Carl David Tolmé Runge

Born: 1856 in Bremen, Germany

Died: 1927 in Göttingen, Germany

Page 25: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt25

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Bruce Mayer, PELicensed Electrical & Mechanical Engineer

[email protected]

Engr/Math/Physics 25

Appendix 6972 23 xxxxf

Page 26: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt26

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

2nd Order ODE SUMMARY-1 If

NonHomogeneous Then find ANY Particular Solution

Next HOMOGENIZE the ODE

The Soln to the Homog. Eqn Produces the Complementary Solution, yc

Assume yc take this form

CONST) (a 63/18

18)(3)(7)(5 2

2

py

tytdtdyt

dtyd

stc

stc

stc

Aesty

sAety

Aety

2

0)(3)(7)(5 2

2

tytdtdyt

dtyd

Page 27: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt27

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

2nd Order ODE SUMMARY-2 Subbing yc = Aest

into the Homog. Eqn yields the Characteristic Eqn

Find the TWO roots that satisfy the Char Eqn by Quadratic Formula

Check FORM of Roots

If s1 & s2 → REAL & UNequal

0375 2 ss tstsc eGeGty 2

211

5235477 2

2,1

s

• Decaying Contant(s)

Page 28: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt28

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

2nd Order ODE SUMMARY-3 If s1 & s2 → REAL

& Equal, then s1 = s2 =s

• Decaying Line If s1 & s2 → Complex

Conjugates then

• Decaying Sinusoid Add Particlular &

Complementary Solutions to yield the Complete Solution

constants are b m,

bmtety stc

tBtBety atc sincos 21

pc yyty

Page 29: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt29

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

2nd Order ODE SUMMARY-4 To Find Constant

Sets: (G1, G2), (m, b), (B1, B2) Take for COMPLETE solution

Find Number-Values for the constants to complete the solution process

00

0

1

00

yICdtdy

yICty

t• Yields 2 eqns in 2 for

the 2 Unknown Constants

Page 30: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt30

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Finite Difference Methods - 1 Another way of

thinking about numerical methods is in terms of finite differences.

Use the Approximation

And From the Differential Eqn

From these two equations obtain:

n

nn

dtdy

tyy

1

),( nnn

ytfdtdy

Recognize as the Euler Method

),(1nn

nn ytftyy

Page 31: ENGR-25_Lec-21_Integ_Diff.ppt 1 Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods Bruce Mayer, PE Licensed Electrical

[email protected] • ENGR-25_Lec-21_Integ_Diff.ppt31

Bruce Mayer, PE Engineering/Math/Physics 25: Computational Methods

Finite Difference Methods - 2 Could make More Accurate by

Approximating dy/dt at the Half-Step as the average of the end pts

Recognize as the Predictor-Corrector Method

121

1

21

nnn

nn

dtdy

dtdy

dtdy

tyy

Then Again Use the ODE to Obtain

11

21

nnnn ff

tyy