6
COPYRIGHT: NIELS GRONBECH-JENSEN, UC DAVIS, 2014 NOT FOR DISTRIBUTION DATE: March 10, 2014 DUE: March 17, 2014 at 1:00pm Solution to EME115, homework set #7. 1. We look at the differential equation dy dt = 2 cos 3t 3 sin 2y y (0) = 0 For the methods Euler, Modified Euler, RK2 (a =1), and RK2 (a = 1 2 ) with time step dt: a. Write the methods in the form y n+1 = ···, and state their accu- racy. A: Euler: y n+1 = y n + dtf n (1) f n = 2 cos 3t n 3 sin 2y n (2) with t n = ndt, since the initial condition is given for t 0 =0. The method is first order (power of the lowest order of dt in the leading error term of the global error). Modified Euler: y n+1 = y n-1 +2dtf n (3) f n = 2 cos 3t n 3 sin 2y n (4) with t n = ndt, since the initial condition is given for t 0 =0. The method is second order (power of the lowest order of dt in the leading error term of the global error). RK2 – a =1: ˜ y n+1 = y n + dtf n (5) y n+1 = y n + dt 2 (f n + ˜ f n+1 ) (6) f n = 2 cos 3t n 3 sin 2y n (7) ˜ f n+1 = 2 cos 3t n+1 3 sin 2˜ y n+1 (8) with t n = ndt, since the initial condition is given for t 0 =0. The method is second order (power of the lowest order of dt in DEPARTMENT OF APPLIED SCIENCE | UNIVERSITY OF CALIFORNIA | DAVIS,CALIFORNIA 95616 TEL: 530.752.0360 | FAX: 530.752.2444

SHW7

Embed Size (px)

Citation preview

Page 1: SHW7

COPYRIGHT: NIELS GRONBECH-JENSEN, UC DAVIS, 2014

NO

T F

OR

DIS

TR

IBU

TIO

NDATE: March 10, 2014

DUE: March 17, 2014 at 1:00pmSolution to EME115, homework set #7.

1. We look at the differential equation

dy

dt= 2 cos 3t− 3 sin 2y

y(0) = 0

For the methods Euler, Modified Euler, RK2 (a = 1), and

RK2 (a = 1

2) with time step dt:

a. Write the methods in the form yn+1 = · · ·, and state their accu-

racy.

A:

Euler:

yn+1 = yn + dtfn (1)

fn = 2 cos 3tn − 3 sin 2yn (2)

with tn = ndt, since the initial condition is given for t0 = 0.

The method is first order (power of the lowest order of dt in the

leading error term of the global error).

Modified Euler:

yn+1 = yn−1 + 2dtfn (3)

fn = 2 cos 3tn − 3 sin 2yn (4)

with tn = ndt, since the initial condition is given for t0 = 0.

The method is second order (power of the lowest order of dt in

the leading error term of the global error).

RK2 – a = 1:

yn+1 = yn + dtfn (5)

yn+1 = yn +dt

2(fn + fn+1) (6)

fn = 2 cos 3tn − 3 sin 2yn (7)

fn+1 = 2 cos 3tn+1 − 3 sin 2yn+1 (8)

with tn = ndt, since the initial condition is given for t0 = 0.

The method is second order (power of the lowest order of dt in

DEPARTMENT OF APPLIED SCIENCE | UNIVERSITY OF CALIFORNIA | DAVIS, CALIFORNIA 95616

TEL: 530.752.0360 | FAX: 530.752.2444

Page 2: SHW7

COPYRIGHT: NIELS GRONBECH-JENSEN, UC DAVIS, 2014

NO

T F

OR

DIS

TR

IBU

TIO

NSolution to EME115, homework set #7. Page 2

the leading error term of the global error).

RK2 – a = 1

2:

yn+

1

2

= yn +1

2dtfn (9)

yn+1 = yn + dtfn+

1

2

(10)

fn = 2 cos 3tn − 3 sin 2yn (11)

fn+

1

2

= 2 cos 3tn+1 − 3 sin 2yn+

1

2

(12)

with tn = ndt, since the initial condition is given for t0 = 0.

The method is second order (power of the lowest order of dt in

the leading error term of the global error).

b. Find the stability limits for the methods.

A:

The linearized, homogeneous problem is

d2y

dt2= −6y (13)

which means that κ = 6. Thus the stability properties are:

Euler: dt < 1/3

Modified Euler: unstable for any dt

RK2–a = 1: dt < 1/3

RK2–a = 1

2: dt < 1/3.

c. Determine for what range of dt the trajectory may be considered

reasonable – state what you mean by reasonable.

A:

The dt ranges for which the dynamics resembles the correct dy-

namics:

Euler: dt < 1/6

Modified Euler: unstable for any dt

RK2–a = 1: dt < 1/3 (or dt < 1/6 depending on your crite-

rion)

RK2–a = 1

2: dt < 1/3 (or dt < 1/6 depending on your crite-

rion).

d. For dt = 0.1 conduct four time steps with each method to arrive

at y4. Specifically, consider how to initiate Modified Euler.

A:

2

Page 3: SHW7

COPYRIGHT: NIELS GRONBECH-JENSEN, UC DAVIS, 2014

NO

T F

OR

DIS

TR

IBU

TIO

NSolution to EME115, homework set #7. Page 3

Euler:n tn yn

0 0.000000000 0.000000000

1 0.100000000 0.200000000

2 0.200000000 0.274241795

3 0.300000000 0.282890763

4 0.400000000 0.246390040

Modified-Euler: Using a back-step Euler step to generate y−1

n tn yn

-1 -0.100000000 -0.200000000

0 0.000000000 0.000000000

1 0.100000000 0.200000000

2 0.200000000 0.148483590

3 0.300000000 0.354561353

4 0.400000000 0.006426650

RK2–a = 1n tn yn yn

0 0.000000000 . . . . . . . . . . . 0.000000000

1 0.100000000 0.200000000 0.137120898

2 0.200000000 0.246943052 0.203457862

3 0.300000000 0.249791350 0.216926711

4 0.400000000 0.215137606 0.189699792

RK2–a = 1

2

n tn yn− 1

2

yn

0 0.000000000 . . . . . . . . . . . 0.000000000

1 0.100000000 0.100000000 0.138153416

2 0.200000000 0.192766400 0.205426972

3 0.300000000 0.228051681 0.219628800

4 0.400000000 0.217999648 0.192448083

e. State how you might assess the global error(s) on y4 as obtained

from the four methods.

A:

This is a perfect case for Richard Extrapolation. Consider ap-

proximating the value y(t4) by four time steps of size dt and,

say, two time steps of size 2dt. Let’s call these approximations

for y4 and y4. If the method is one of order q, we have

y4 = y(t4) + ξdtq + ηdtq+r (14)

y4 = y(t4) + 2qξdtq + 2q+rηdtq+r (15)

We can then provide a new, and better, approximation of the

3

Page 4: SHW7

COPYRIGHT: NIELS GRONBECH-JENSEN, UC DAVIS, 2014

NO

T F

OR

DIS

TR

IBU

TIO

NSolution to EME115, homework set #7. Page 4

form

y(t4) =2qy4 − y42q − 1

(16)

We can then use this as a reference to evaluate the previously

found approximations y4.

2. We look at the differential equation

d2r

dt2= f = 12

Eτ 20mσ

[

(

1

r + 1

)13

−(

1

r + 1

)7]

r(0) = r0 = 0.1

v(0) = v0 = 0.2

a. Linearize the equation of motion for |r| ≪ 1 and write the re-

sulting equation in the form

d2r

dt2= −κr

Determine κ as given by the parameters given above.

A:

We have

df

dr

r=0

= −12Eτ 20mσ

[

13(

1

r + 1

)14

− 7(

1

r + 1

)8]∣

r=0

(17)

= −72Eτ 20mσ

(18)

Thus, κ = 72Eτ2

0

mσand the linearized (and homogenized) equation

is

d2r

dt2= −72

Eτ 20mσ

r (19)

Now, setEτ2

0

mσ= 1.

b. Write the Euler map for the problem (not the linearized one),

and determine the dt-range of stability. Conduct four time steps

with dt = 0.1. List all values for both rn and vn.

A:

rn+1 = rn + dtvn (20)

vn+1 = vn + dtfn (21)

fn = 12

[

(

1

rn + 1

)13

−(

1

rn + 1

)7]

(22)

4

Page 5: SHW7

COPYRIGHT: NIELS GRONBECH-JENSEN, UC DAVIS, 2014

NO

T F

OR

DIS

TR

IBU

TIO

NSolution to EME115, homework set #7. Page 5

The method is unstable for any dt > 0.

n tn rn vn

0 0.000000000 0.100000000 0.200000000

1 0.100000000 0.120000000 -2.012039651

2 0.200000000 -0.081203965 -5.398482593

3 0.300000000 -0.621052224 -5.138626383

4 0.400000000 -1.134914863 -5.100079951

c. Write the RK2 map (a = 1) for the problem (not the linearized

one), and determine the dt-range of stability. Conduct four time

steps with dt = 0.1. List all values for both rn and vn.

A:

rn+1 = rn + dtvn (23)

vn+1 = vn + dtfn (24)

rn+1 = rn +dt

2(vn + vn+1) = rn + dtvn +

dt2

2fn (25)

vn+1 = vn +dt

2(fn + fn+1) (26)

fn = 12

[

(

1

rn + 1

)13

−(

1

rn + 1

)7]

(27)

fn+1 = 12

(

1

rn+1 + 1

)13

−(

1

rn+1 + 1

)7

(28)

The method is unstable for any dt > 0.

n tn rn vn

0 0.000000000 0.100000000 0.200000000

1 0.100000000 0.009398017 -2.599241297

2 0.200000000 -0.254262515 -2.543951701

3 0.300000000 -0.499526815 -2.421773702

4 0.400000000 -0.738494322 -2.377776699

d. Write the Modified Euler map (as we did today in class [March

10, 2014]) for the problem (not the linearized one), and deter-

mine the dt-range of stability. Conduct four time steps with

dt = 0.1. List all values for both rn and vn. Notice that we

may use

v 1

2

= v0 +dt

2f0

vn =rn+1 − rn−1

2dt

5

Page 6: SHW7

COPYRIGHT: NIELS GRONBECH-JENSEN, UC DAVIS, 2014

NO

T F

OR

DIS

TR

IBU

TIO

NSolution to EME115, homework set #7. Page 6

Updated lecture notes will arrive shortly.

A:

rn+1 = rn + dtvn+

1

2

(29)

fn+1 = 12

(

1

rn+1 + 1

)13

−(

1

rn+1 + 1

)7

(30)

vn+

3

2

= vn+

1

2

+ dtfn+1 (31)

vn+1 =1

2(v

n+1

2

+ vn+

3

2

) (32)

The method is stable for dt < 2/√72 ≈ 0.236.

n tn rn vn

0 0.000000000 0.100000000 0.200000000

1 0.100000000 0.009398017 -0.943383854

2 0.200000000 -0.088676771 -0.848546762

3 0.300000000 -0.160311335 -0.591278848

4 0.400000000 -0.206932540 -0.357413077

All calculations with at least eight significant digits.

Niels Grønbech Jensen

6