• No results found

Numerical Solution of Differential Equations

N/A
N/A
Protected

Academic year: 2021

Share "Numerical Solution of Differential Equations"

Copied!
48
0
0

Loading.... (view fulltext now)

Full text

(1)

Numerical Solution of

Differential Equations

3rd year JMC group project ● Summer Term 2004

Supervisor: Prof. Jeff Cash

Saeed Amen Paul Bilokon

Adam Brinley Codd Minal Fofaria

Tejas Shah

(2)

Agenda

z Adam: Differential equations and numerical methods

z Paul: Basic methods (FE, BE, TR). Problem:

“circle”

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(3)

Agenda

z Adam: Differential equations and numerical methods

z Paul: Basic methods (FE, BE, TR). Problem:

“circle”

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(4)

Introduction to Differential

Equations

z Equations involving a function y of x, and its derivatives

z Model real world systems

z General Equation:

(5)

Introduction to Differential

Equations

z Simple example

z Solution obtained by integrating both sides

z Initial values can determine c

(6)

Introduction to Differential

Equations

z Special case when equations do not involve x

z E.g.

z Initial values y(0) = 1 and y'(0) = 0, solution is

(7)

Introduction to Differential

Equations

z Kepler’s Equations of Planetary Motion

z Difficult to solve analytically – we use numerical methods instead

(8)

Introduction to Differential

Equations

z Forward Euler and Backward Euler

z Trapezium Rule

z General method

Use initial value of y at x=0

Calculate next value (x=h for small h) using gradient

Call this y1 and repeat

z Need formula for yn+1 in terms of yn

(9)

Agenda

z Adam: Differential equations and numerical methods

z Paul: Basic methods (FE, BE, TR). Problem:

“circle”

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(10)

Agenda

z Adam: Differential equations and numerical methods 3

z Paul: Basic methods (FE, BE, TR). Problem:

“circle”

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(11)

Euler’s Methods

z Simplest way of solving ODEs numerically

z Does not always

produce reasonable solutions

z Forward Euler (explicit) and Backward Euler

(implicit)

(12)

Forward Euler

z y(x + h) = y(x) + h y’(x)

z Explicit

z Eloc = ½h2y(2)(ξ) h2

z First order

z Asymmetric

x0 x1 x2 x

y

y0 y1 y2

h h

(x0, y0)

(x1, y1)

(x2, y2) True solution

Approximated solution Slope f(x1, y1) Slope f(x0, y0)

(13)

Backward Euler

z y(x + h) = y(x) + h y’(x + h)

z Implicit

z Eloc = - ½h2y(2)(ξ) h2

z First order

z Asymmetric

x0 x1 x2 x

y

y0 y1 y2

h h

(x0, y0)

(x1, y1)

(x2, y2)

True solution

Approximated solution Slope f(x2, y2) Slope f(x1, y1)

(14)

Trapezium Rule

z y(x + h) = y(x) + ½ h [y’(x) + y’(x + h)]

z Average of FE and BE

z Implicit

z Eloc = - (h3/12) f(2)(ξ) h3

z Second order

z Symmetric

(15)

Example Problem: “Circle”

z Consider y’’ = -y, with initial conditions

y(0) = 1

y’(0) = 0

z The analytical solution is y = cos x, that can be

used for comparison with numerical solutions

(16)

Plots for the True Solution

Time series plot (xy) Phase plane plot (zy)

(17)

Time Series

y

x

(18)

Phase Plane Plots: FE & BE

Forward Euler Backward Euler

(19)

Phase Plane Plots: TR

z FE & BE fail: non-periodic

z TR: OK, periodic soln

W h y ?

(20)

Symmetricity

z TR is symmetric, whereas FE & BE are not

y(x + h) = y(x) + ½ h [y’(x) + y’(x + h)]

h Æ -h

y(x - h) = y(x) - ½ h [y’(x) + y’(x - h)]

X := x - h

y(X + h) = y(X) + ½ h [y’(X) + y’(X + h)]

Still TR!

(21)

Symmetricity

z TR is symmetric, whereas FE & BE are not

y(x + h) = y(x) + h y’(x) h Æ -h

y(x - h) = y(x) - h y’(x) X := x - h

y(X + h) = y(X) + h y’(X + h)

Still FE?

(22)

Time Step

h = 10 -1 h = 10 -2

(23)

Agenda

z Adam: Differential equations and numerical methods 3

z Paul: Basic methods (FE, BE, TR). Problem:

“circle”

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(24)

Agenda

z Adam: Differential equations and numerical methods 3

z Paul: Basic methods (FE, BE, TR). Problem:

“circle” 3

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(25)

After Euler and TR

z Can create higher order methods, which have far smaller global errors

z Methods are more complex and require more computation on each step

z But for same step size more accurate

z Introduce concept of half step

(26)

Two Fourth Order Methods

z yn+1 – yn = yn + h/2(y’n) + (h2/12)(4y’’n+½+ 2y’’n)

z y’n+1 – y’n = h/6(y’’n+1 + 4y’’n+½+ y’’n) (*)

z Then to calculate the half-step we use either A or B

A) yn+ ½= ½(yn+1 + yn) – h2/48(y’’n+1 + 4y’’ n+½ + y’’n)

B) yn+ ½= yn + ½y’n – h2/192(-2y’’n+1 + 12y’’ n+½ + 14y’’n) z Which one is more accurate? (next slide)

z Solve iteratively and then apply solution to find derivative (*)

(27)

Creating Method A

z Start with

yn+1 – yn = h/6[y’n+1 + 4y’n+½ + y’n] (1)

diff. y’n+1 – y’n = h/6[y’’n+1 + 4y’’n+½ + y’’n] (2)

yn+½= ½(yn+1 + y’n) – h/8(y’n+1 – y’n) (3)

diff. y’n+½= ½(y’n+1 + y’’n) – h/8(y’’n+1 – y’’n) (4)

z subs (4) into (1) (to eliminate y’n+½ ) and eliminate y’n+1 using (2),

z then use (2) in (3) to get half-step

(28)

Comparing Fourth Order Methods

z Comparing errors when solving circle problem

z Both A and B produce a much smaller order of error than Euler’s

(29)

Finding Earth’s Orbit Around Sun

z Kepler’s Equation

z Can use it to find the orbit of planets

z Use to find orbit of earth around the sun

z Work in two dimensions z and y

z z’’ = -(GM z) / (y2 + z2)3/2 y’’ = -(GM y) / (y2 + z2)3/2

z Constants and initial conditions in report

(30)

Results Plot

z Solution uses small step size h = 0.01

z Becomes difficult to tell difference between

methods visually

z Using h = 0.1 difference is more marked

(31)

Agenda

z Adam: Differential equations and numerical methods 3

z Paul: Basic methods (FE, BE, TR). Problem:

“circle” 3

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(32)

Agenda

z Adam: Differential equations and numerical methods 3

z Paul: Basic methods (FE, BE, TR). Problem:

“circle” 3

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation 3

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(33)

Stiff Equations

z Certain systems of ODEs are classified as stiff

z A system of ODEs is stiff if there are two or more very different scales of the independent variable on which the dependent variables are changing

z Some of the methods used to find numerical solutions fail to obtain the required solution

(34)

Example

z Consider the equation:

z With initial conditions:

z There are two solutions to this problem

0 )

1

2 (

2 + + + y =

dx dy dx

y

d λ λ

1 )

0 ( = y

1 )

0 (

' = y

(35)

Example continued

z Analytical solution: y=e-x

z Unwanted solution: y=e-λx

z We will now show how forward Euler is not

stable when solving this problem under certain circumstances

(36)

Example continued

z Let λ = 103 and let (the step size) h = 0.1

(37)

Increasing the range of the x-axis

(38)

When h = 0.001

(39)

Agenda

z Adam: Differential equations and numerical methods 3

z Paul: Basic methods (FE, BE, TR). Problem:

“circle” 3

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation 3

z Minal: Stiff equations

z Tejas: Derivation of 6th order method

(40)

Agenda

z Adam: Differential equations and numerical methods 3

z Paul: Basic methods (FE, BE, TR). Problem:

“circle” 3

z Saeed: Advanced methods (4th order).

Problem: Kepler’s equation 3

z Minal: Stiff equations 3

z Tejas: Derivation of 6th order method

(41)

A Sixth Order Numerical Method

z Has an error term with smallest h degree as h7

z Idea is to find values for α, A, B, C, D, E, F, C, D, E, F such that:

(42)

Derivation

z Compare Taylor’s Expansion of LHS and RHS

z So for:

First expand the LHS

(43)

Derivation

• Now expand individual terms on RHS of our expression:

• This gives:

(44)

Derivation

z Equate both sides and solve for constants:

z Similarly we can find C, D, E, F and C, D, E, F

(45)

Applying 6

th

Order Method

z How to obtain results using derived method.

z Produce a set of simultaneous equations and solve.

z Find y’n+1 from old values and those just obtained.

z Set x, yn , y’n etc. to new values.

z Repeat above procedure with updated variables.

(46)

Circle Problem Example

z Circle is produced for phase plane plot

(47)

Kepler’s Equations

• Solution obtained from z-y plot reinforces fourth order method results.

(48)

The End

But perhaps you want more?

z Read our report

z Visit our website:

http://www.doc.ic.ac.uk/~pb401/DE

References

Related documents

These authors suggest that the 1131 test might be useful in the early diagnosis of athyrotic cretinism.. It should be strongly cautioned that the uptake of radioactive iodine may

Dorsal surface of abdomen dark brown except segment 2 light brown (though posterior one-fourth of dorsal surface brown), covered with dark brown short to long

In the proposed scheme, the algorithm first selects the protected points from the user’s trajectory data; secondly, the algorithm builds the polygons according to the protected

Vestiture comprises scales of various shapes and sizes on different body parts: head and pronotum covered densely with erect oblong pale fl at or peg-shaped scales and dark

The current study aims at finding out the reality of using modern teaching methods in teaching Arabic for speakers of other languages from teachers’ perspective in the

1) whether the item actually sold during the auction, 2) value of the final bid, 3) starting bid for the auction, 4) stated shipping charges for the product being sold, 5) presence

Joining networking groups will allow you to spread the word about what your new business does and how it can help the people you talk to or their referrals.. One of