ODE lecture 1

54
ENGR90024 COMPUTATIONAL FLUID DYNAMICS Lecture O01 Ordinary Differential Equations (ODEs): Introduction & Taylor series (Pages 1-4 of the Printed Lecture Notes)

description

This is a lecture note on CFD course taught at University of Melbourne. It is mainly about the overview of the course and some basic knowledge on ODE topic.

Transcript of ODE lecture 1

Page 1: ODE lecture 1

ENGR90024 COMPUTATIONAL FLUID DYNAMICS

Lecture O01

Ordinary Differential Equations (ODEs):!

Introduction & Taylor series!

(Pages 1-4 of the Printed Lecture Notes)!

!

Page 2: ODE lecture 1

Mathematical equations that govern fluid flow

Page 3: ODE lecture 1

OpenFoam

Supercomputer

x PREFACE

(a) (b)

(c) (d)

(e) (f)

Figure 1: Some example applications in science and engineering which involve thesolution of ordinary and partial di↵erential equations.

x PREFACE

(a) (b)

(c) (d)

(e) (f)

Figure 1: Some example applications in science and engineering which involve thesolution of ordinary and partial di↵erential equations.

x PREFACE

(a) (b)

(c) (d)

(e) (f)

Figure 1: Some example applications in science and engineering which involve thesolution of ordinary and partial di↵erential equations.

Page 4: ODE lecture 1
Page 5: ODE lecture 1
Page 6: ODE lecture 1
Page 7: ODE lecture 1
Page 8: ODE lecture 1

Lecture & Workshop timetable3 MODULES!•ORDINARY DIFFERENTIAL EQUATIONS (ODE)!•PARTIAL DIFFERENTIAL EQUATIONS (PDE)!•OPENFOAM(HTTP://WWW.OPENFOAM.ORG)

Page 9: ODE lecture 1

Lecture & Workshop timetable

Week Starting Tue-morning Tues-afternoon Wed-Workshop Thu

1 Mar 3 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi

Workshop on Linux/C++/ODEs

Lecture on ODEs Prof Andrew Ooi

2 Mar 10 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

3 Mar 17 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

4 Mar 24 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

5 Mar 31 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

6 Apr 7 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson

Consultation for Assignment 1

Lecture on PDEs A/Prof Malcolm Davidson

7 Apr 14 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on OpenFOAM Lecture on PDEs

A/Prof Malcolm Davidson

Apr 21 Break

Break

Break

Break

8 Apr 28 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

9 May 5 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

10 May 12 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on OpenFOAM

Dr Stephen Moore

11 May 19 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

12 May 26 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

Assignment 1 due!18th April

Assignment 2 due!30th May

Page 10: ODE lecture 1

Lecture & Workshop timetable

Week Starting Tue-morning Tues-afternoon Wed-Workshop Thu

1 Mar 3 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi

Workshop on Linux/C++/ODEs

Lecture on ODEs Prof Andrew Ooi

2 Mar 10 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

3 Mar 17 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

4 Mar 24 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

5 Mar 31 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

6 Apr 7 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson

Consultation for Assignment 1

Lecture on PDEs A/Prof Malcolm Davidson

7 Apr 14 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on OpenFOAM Lecture on PDEs

A/Prof Malcolm Davidson

Apr 21 Break

Break

Break

Break

8 Apr 28 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

9 May 5 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

10 May 12 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on OpenFOAM

Dr Stephen Moore

11 May 19 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

12 May 26 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

Assignment 1 due!18th April

Assignment 2 due!30th May

Doug McDonell-309!11am-12pm

Page 11: ODE lecture 1

Lecture & Workshop timetable

Week Starting Tue-morning Tues-afternoon Wed-Workshop Thu

1 Mar 3 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi

Workshop on Linux/C++/ODEs

Lecture on ODEs Prof Andrew Ooi

2 Mar 10 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

3 Mar 17 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

4 Mar 24 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

5 Mar 31 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

6 Apr 7 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson

Consultation for Assignment 1

Lecture on PDEs A/Prof Malcolm Davidson

7 Apr 14 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on OpenFOAM Lecture on PDEs

A/Prof Malcolm Davidson

Apr 21 Break

Break

Break

Break

8 Apr 28 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

9 May 5 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

10 May 12 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on OpenFOAM

Dr Stephen Moore

11 May 19 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

12 May 26 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

Assignment 1 due!18th April

Assignment 2 due!30th May

Alan Gilbert Theatre 2!5:15pm-6:15pm

Page 12: ODE lecture 1

Lecture & Workshop timetable

Week Starting Tue-morning Tues-afternoon Wed-Workshop Thu

1 Mar 3 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi

Workshop on Linux/C++/ODEs

Lecture on ODEs Prof Andrew Ooi

2 Mar 10 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

3 Mar 17 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

4 Mar 24 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

5 Mar 31 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

6 Apr 7 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson

Consultation for Assignment 1

Lecture on PDEs A/Prof Malcolm Davidson

7 Apr 14 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on OpenFOAM Lecture on PDEs

A/Prof Malcolm Davidson

Apr 21 Break

Break

Break

Break

8 Apr 28 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

9 May 5 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

10 May 12 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on OpenFOAM

Dr Stephen Moore

11 May 19 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

12 May 26 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

Assignment 1 due!18th April

Assignment 2 due!30th May

Doug McDonell-503!2:15pm-3:15pm

Page 13: ODE lecture 1

Lecture & Workshop timetable

Week Starting Tue-morning Tues-afternoon Wed-Workshop Thu

1 Mar 3 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi

Workshop on Linux/C++/ODEs

Lecture on ODEs Prof Andrew Ooi

2 Mar 10 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

3 Mar 17 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

4 Mar 24 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on ODEs Lecture on OpenFOAM

Dr Stephen Moore

5 Mar 31 Lecture on ODEs Prof Andrew Ooi

Lecture on ODEs Prof Andrew Ooi Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

6 Apr 7 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson

Consultation for Assignment 1

Lecture on PDEs A/Prof Malcolm Davidson

7 Apr 14 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on OpenFOAM Lecture on PDEs

A/Prof Malcolm Davidson

Apr 21 Break

Break

Break

Break

8 Apr 28 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

9 May 5 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on PDEs

A/Prof Malcolm Davidson

10 May 12 Lecture on PDEs A/Prof Malcolm Davidson

Lecture on PDEs A/Prof Malcolm Davidson Workshop on PDEs Lecture on OpenFOAM

Dr Stephen Moore

11 May 19 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

12 May 26 Lecture on OpenFOAM Dr Stephen Moore

Lecture on OpenFOAM Dr Stephen Moore Workshop on OpenFOAM Lecture on OpenFOAM

Dr Stephen Moore

Assignment 1 due!18th April

Assignment 2 due!30th May

Old Engineering - EDS 1!12:00pm-2:00pm

Page 14: ODE lecture 1

Assessment

•10% Workshops (weekly)-1% satisfactory completion of every workshop-11 workshops in total so can afford to miss 1

•10% Assignment 1 (Due 18th April)-ODE & OpenFOAM

•20% Assignment 2 (Due 30th May)-PDE & OpenFOAM

•60% end of semester exam -ODE, PDE & OpenFOAM-Exam is a Hurdle. Need to pass the exam to pass this subject!!!!

Page 15: ODE lecture 1

Student comments“Open foam should be introduced in the workshops much earlier than they were”

• Last year, OpenFOAM workshops were not introduced until week 4• We will be introducing OpenFOAM workshop in week 3. There could also be

! OpenFOAM material in workshops in weeks 1 and 2.

“Assignments should have been released earlier”• Assignment 1 (due week 7) will be released week 1 or 2 of the semester• We will release assignment 2 in week 8 (last year was released in week 10).

Page 16: ODE lecture 1

Ordinary Differential EquationsIn the most generic form, ordinary differential equations (ODE) can bewritten as

g

✓dN�

dtN, · · · , d

3�

dt3,d2�

dt2,d�

dt,�, t

◆= 0

where N is the order of the ODE.

a(t)d3�

dt3+ b(t)

d2�

dt2+ c(t)

d�

dt+ d(t)�+ e(t) = 0

then the ODE is linear.

(O01.1)

(O01.2)

If every term in the ODE is linear, then the ODE is linear. If even one!term of the ODE is nonlinear, then the ODE is nonlinear.

If g is a linear function, e.g.

If g is a nonlinear function, then the ODE is nonlinear.

Page 17: ODE lecture 1

Example O01.1: For the ODEs shown below, state the order of the ODE and if the ODE is linear/nonlinear. a, b and c are constants.!

(a) t2d2�

dt2+ at

d�

dt+ b� = c

(b)d2�

dt2� a

�1� �2

� d�dt

+ � = 0

Page 18: ODE lecture 1

(a) t2d2�

dt2+ at

d�

dt+ b� = c

Let’s look at equation (a).

Linear Linear Linear

Linear

Since all terms in the above equations are linear, the ODE is a linear ODE

Page 19: ODE lecture 1

Let’s now look at (b)

(b)d2�

dt2� a

�1� �2

� d�dt

+ � = 0

d2�

dt2� a

d�

dt+ �2 d�

dt+ � = 0

LinearLinear

Linear

Nonlinear

Page 20: ODE lecture 1

Let’s now look at (b)

(b)d2�

dt2� a

�1� �2

� d�dt

+ � = 0

d2�

dt2� a

d�

dt+ �2 d�

dt+ � = 0

LinearLinear

Linear

Nonlinear

Since the third term in the above equation is nonlinear, the ODE is a nonlinear ODE!

Page 21: ODE lecture 1

End of Example O01.1

Page 22: ODE lecture 1

In many engineering problems, Eq. (O01.1) can be written as

Eq. (O01.3) is solved usually solved in the domain

with the initial condition

(O01.3)d�

dt= f(t,�)

tmin

t tmax

�(tmin) = �min

Initial Value Problem

Page 23: ODE lecture 1

d�

dt= f(t,�)

tmin

t tmax

�(tmin) = �min

Initial Value Problem

Mathematical MethodsExact (true) solution

Approximate solution

Numerical/Computer Methods

Compare

Page 24: ODE lecture 1

Example O01.2: !Solve the following ordinary differential equation (ODE)!!!!!with ɸ(t=0)=0. Use MATLAB to plot the solution for 0 < t < 8.

d�

dt= 1� � (O01.4)

d�

dt= f(t,�)

tmin

t tmax

�(tmin) = �min

Initial Value Problem

Mathematical MethodsExact (true) solution

Approximate solution

Numerical/Computer Methods

Compare

Page 25: ODE lecture 1

d�

dt= 1� �

d�

dt+ � = 1

Use integrating factor, multiply both sides by et

etd�

dt+ et� = et

d

dt

�et�

�= et

Integrating gives

1

Page 26: ODE lecture 1

et� = et +K

Where K is a constant. We are given that ɸ=0 when t=0. Substituting!into the above equation gives

1⇥ 0 = 1 +K

K = �1Thus the solution to Eq. (O01.4) is

� = 1� e�t

e0 ⇥ 0 = e0 +K

Page 27: ODE lecture 1

function MPO01p2() !!t=0:0.1:8; phi=1-exp(-t); !plot(t,phi); !xlabel('t'); ylabel('\phi(t)');

t=[0.0 0.1 0.2 0.3 0.4........8.0]

phi=[0.0 0.0952 0.1813 0.2592 ........ 1.0]

1-e-0.0 1-e-0.2 1-e-8.0

1-e-0.1 1-e-0.3

0 1 2 3 4 5 6 7 80

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

t

φ(t)

Page 28: ODE lecture 1

End of Example O01.2

Page 29: ODE lecture 1

d�

dt= f(t,�)

tmin

t tmax

�(tmin) = �min

Initial Value Problem

Mathematical MethodsExact solution

Approximate solution

Numerical/Computer Methods

Compare

� = 1� e�t

0 1 2 3 4 5 6 7 80

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

t

φ(t)

Page 30: ODE lecture 1

d�

dt= f(t,�)

tmin

t tmax

�(tmin) = �min

Initial Value Problem Approximate solution

Numerical/Computer Methods

Page 31: ODE lecture 1

Taylor series

TheTaylor series expansion of a function ɸ(t) about the pointtl can be written as

tl+1=tl+Δt.

�(tl+1) = �(tl) +�t

1!

d�

dt

����tl+

�t2

2!

d2�

dt2

����tl+

�t3

3!

d3�

dt3

����tl+ . . .

(O01.5)�(tl+1) =1X

n=0

(tl+1 � tl)n

n!dn�

dtn

����tl

(O01.6)

Equation (O01.5) can be expanded to look like

Page 32: ODE lecture 1

Example O01.3: Find the Taylor series for the function!!!!Plot the first few terms of this function and show that you can get closer to the original function if you use the more terms in the series.

�(t) = sin(t)

Page 33: ODE lecture 1

�(tl+1) = �(tl) +�t

1!

d�

dt

����tl+

�t2

2!

d2�

dt2

����tl+

�t3

3!

d3�

dt3

����tl+ . . .

If tl=0, then tl+1=Δt=t

�(t) = �(0) +t

1!

d�

dt

����0

+t2

2!

d2�

dt2

����0

+t3

3!

d3�

dt3

����0

+ . . .

You are given that ɸ(t)=sin(t), so

ɸ(0)=sin(0)=0!dɸ/dt(0)=cos(0)=1.0!

d2ɸ/dt2(0)=-sin(0)=0.0!d3ɸ/dt3(0)=-cos(0)=-1.0!d4ɸ/dt4(0)=sin(0)=0.0!d5ɸ/dt5(0)=cos(0)=1.0

From Eq. (O01.6), the Taylor’s series can be written as

Page 34: ODE lecture 1

�(tl+1) = �(tl) +�t

1!

d�

dt

����tl+

�t2

2!

d2�

dt2

����tl+

�t3

3!

d3�

dt3

����tl+ . . .

If tl=0, then tl+1=Δt=t

�(t) = �(0) +t

1!

d�

dt

����0

+t2

2!

d2�

dt2

����0

+t3

3!

d3�

dt3

����0

+ . . .

You are given that ɸ(t)=sin(t), so

ɸ(0)=sin(0)=0!dɸ/dt(0)=cos(0)=1.0!

d2ɸ/dt2(0)=-sin(0)=0.0!d3ɸ/dt3(0)=-cos(0)=-1.0!d4ɸ/dt4(0)=sin(0)=0.0!d5ɸ/dt5(0)=cos(0)=1.0

From Eq. (O01.6), the Taylor’s series can be written as

Page 35: ODE lecture 1

Substituting into the Taylor series Eq. (O01.6) gives!

�(t) = sin(t) = t� (1/6)t3

+(1/120)t5

�(1/5040)t7

+ . . .

Page 36: ODE lecture 1

�(t) = t

−4 −3 −2 −1 0 1 2 3 4−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

t

Page 37: ODE lecture 1

�(t) = t�(1/6)t3

−4 −3 −2 −1 0 1 2 3 4−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

t

t−(1/6) t3φ

Page 38: ODE lecture 1

�(t) = t�(1/6)t3+(1/120)t5

−4 −3 −2 −1 0 1 2 3 4−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

t

t−(1/6) t3+(1/120) t5φ

Page 39: ODE lecture 1

�(t) = t�(1/6)t3+(1/120)t5�(1/5040)t7

−4 −3 −2 −1 0 1 2 3 4−1

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

t

t−(1/6) t3+(1/120) t5−(1/5040) t7φ

Page 40: ODE lecture 1

End of Example O01.3

Page 41: ODE lecture 1

Sometimes it is convenient to group all higher order terms of theTaylorsseries into a single term. For example,

�(tl+1) = �(tl) +�t

1!

d�

dt(tl) +

�t2

2!

d2�

dt2(tl) +

�t3

3!

d3�

dt3(tl) +

�t4

4!

d4�

dt4(tl) + . . .

can be written as

or

�(tl+1) = �(tl) +�t

1!

d�

dt(⇠2)

where tl < ξ1 < tl+1 , tl < ξ2 < tl+1 and ξ1 ≠ ξ2

(O01.7)

(O01.8)

�(tl+1) = �(tl) +�t

1!

d�

dt(tl) +

�t2

2!

d2�

dt2(⇠1)

Page 42: ODE lecture 1

�(tl+1) = �(tl) +�t

1!

d�

dt(tl) +

�t2

2!

d2�

dt2(tl) +

�t3

3!

d3�

dt3(tl) +

�t4

4!

d4�

dt4(tl) + . . .

�(tl+1) = �(tl) +�t

1!

d�

dt(tl)+

�t2

2!

d2�

dt2(⇠)

where ξ is somewhere between tl and tl+1 i.e. tl < ξ < tl+1

Page 43: ODE lecture 1

�(tl+1) = �(tl) +�t

1!

d�

dt(tl) +

�t2

2!

d2�

dt2(tl) +

�t3

3!

d3�

dt3(tl) +

�t4

4!

d4�

dt4(tl) + . . .

�(tl+1) = �(tl) +�t

1!

d�

dt(tl)+

�t2

2!

d2�

dt2(⇠)

where ξ is somewhere between tl and tl+1 i.e. tl < ξ < tl+1

Page 44: ODE lecture 1

Exercise O01.4: For the function!!!!!!

�(t) = sin(t)show the validity of Eqs. (O01.7) & (O01.8) by finding !finding values of ξ1 and ξ2 for tl=0.0 and Δt =π/2.

Equation (O01.8), repeated here

tl+1 = tl +�t

tl ⇠2 tl+1

�(tl+1) = �(tl) +�td�

dt(⇠2)

Page 45: ODE lecture 1

tl+1 = tl +�t

tl ⇠2 tl+1

�(tl+1) = �(tl) +�td�

dt(⇠2)

For this example

tl = 0.0�t = ⇡/2

So

�(t) = sin(t)

tl+1 = 0 + ⇡/2 = ⇡/2

Hence, equation (O01.8), says that

�(tl+1) = sin(tl+1) = sin(⇡/2) = 1

=

�(tl) = sin(tl) = sin(0) = 0

+1 0 ⇡/2

d�

dt(⇠2) = cos (⇠2)

cos (⇠2)

Page 46: ODE lecture 1

1 = 0 + ⇡/2 cos (⇠2)

0 ⇠2 ⇡/2

Illustrate graphically

Page 47: ODE lecture 1

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

t

φ

�t

sin(⇡/2)d�

dt(⇠2 = 0)

sin(0) ⇡/2

sin(0) +�td�

dt(⇠2 = 0)

� = sin(t)

sin(0) +�td�

dt(⇠2 = 0) > sin(⇡/2)

Page 48: ODE lecture 1

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

t

φ

sin(⇡/2)

sin(0)

� = sin(t)d�

dt(⇠2 = ⇡/2)

�tsin(0) +�t

d�

dt(⇠2 = ⇡/2)

sin(0) +�td�

dt(⇠2 = ⇡/2) < sin(⇡/2)

Page 49: ODE lecture 1

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

t

φ

� = sin(t)

sin(⇡/2)

sin(0)

d�

dt(⇠2 = 1.2)

�t

sin(0) +�td�

dt(⇠2 = 1.2)

Page 50: ODE lecture 1

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

t

φ

� = sin(t)

sin(⇡/2)

sin(0)

d�

dt(⇠2 = 1.2)

�t

sin(0) +�td�

dt(⇠2 = 1.2)

sin(0) +�td�

dt(⇠2 = 1.2) 6= sin(⇡/2)

Page 51: ODE lecture 1

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

t

φ

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.2

0.4

0.6

0.8

1

1.2

1.4

1.6

1.8

2

t

φ

⇠2 = 0

⇠2 = ⇡/2

sin(0) +�td�

dt(⇠2 = 0)

sin(0) +�td�

dt(⇠2 = ⇡/2)

sin(⇡/2)

sin(⇡/2)

From the top graph, it is shown that for ξ2=0, the equation

evaluates to a value greater than sin(p/2). From the bottom graph, it is shown that for ξ2= p/2, the equation

evaluates to a value less than sin(p/2). Hence, in order for

sin(0) +�td�

dt(⇠2)

sin(0) +�td�

dt(⇠2)

sin(0) +�td�

dt(⇠2) = sin(⇡/2)

0<ξ2<p/2.

Page 52: ODE lecture 1

sin(⇡/2) = sin(0) +

2

cos(⇠2)

cos(⇠2) =2

⇠2 = 0.8807

Finding the value of ξ2 is easy

Page 53: ODE lecture 1

�t �t

�t�t

⇠2 = 0.0 ⇠2 = 0.5

⇠2 = 0.7 ⇠2 = 0.8807

Page 54: ODE lecture 1

End of Example O01.4