Docsity

Applied Numerical Methods - Homework 1 Solutions | MATH 151A, Assignments of Mathematics

Toggle sidebar
bg1
Homework 1 Solutions
Igor Yanovsky (Math 151B TA)
Theorem 5.4: Suppose that D={(t, y)|a≤t≤b, −∞ < y < ∞} and that f(t,y )
is continuous on D. If fsatisfies a Lipschitz condition on Din the variable y, then the
initial-value problem
y0(t) = f(t, y), a ≤t≤b,
y(a) = α,
has a unique solution y(t) for a≤t≤b.
Section 5.1, Problem 1(d): Use Theorem 5.4 to show that
y0=4t3y
1 + t4,0≤t≤1,
y(0) = 1.
has a unique solution, and find the solution.
Solution: Note that
f(t, y) = 4t3y
1 + t4
is continuous on D={(t, y)|0≤t≤1,−∞ < y < ∞}.
Also, fsatisfies a Lipschitz condition on Din the variable y:
¯
¯
¯
¯
∂f
∂y (t, y)¯
¯
¯
¯
=¯
¯
¯
¯
4t3
1 + t4¯
¯
¯
¯≤2,0≤t≤1.
Thus, the initial-value problem has a unique solution for a≤t≤b.
We now solve the initial-value problem.
dy
dt =4t3y
1 + t4,
Zdy
y=Z4t3
1 + t4dt,
log y= log(1 + t4) + C1,
y=C(1 + t4).
Thus, y(t) = C(1 + t4), and using initial condition, we obtain y(0) = C= 1. Hence, the
solution to the initial value problem is y(t) = 1 + t4.X
It is always recommended to check if your solution (y(t) = 1 + t4) is correct, i.e. whether
it satisfies the initial value problem. Note that,
dy
dt =?4t3y
1 + t4,
4t3=4t3(1 + t4)
(1 + t4),X
and also, y(0) = 1. X
1
pf3
pf4
pf5

Partial preview of the text

Download Applied Numerical Methods - Homework 1 Solutions | MATH 151A and more Assignments Mathematics in PDF only on Docsity!

Homework 1 Solutions

Igor Yanovsky (Math 151B TA)

Theorem 5.4: Suppose that D = {(t, y) | a ≤ t ≤ b, −∞ < y < ∞} and that f (t, y) is continuous on D. If f satisfies a Lipschitz condition on D in the variable y, then the initial-value problem

y′(t) = f (t, y), a ≤ t ≤ b, y(a) = α,

has a unique solution y(t) for a ≤ t ≤ b.

Section 5.1, Problem 1(d): Use Theorem 5.4 to show that

y′^ =

4 t^3 y 1 + t^4 , 0 ≤ t ≤ 1 , y(0) = 1.

has a unique solution, and find the solution.

Solution: Note that

f (t, y) = 4 t^3 y 1 + t^4 is continuous on D = {(t, y) | 0 ≤ t ≤ 1 , −∞ < y < ∞}. Also, f satisfies a Lipschitz condition on D in the variable y: ∣ ∣∣ ∣

∂f ∂y (t, y)

4 t^3 1 + t^4

∣ ≤^2 ,^0 ≤^ t^ ≤^1.

Thus, the initial-value problem has a unique solution for a ≤ t ≤ b.

We now solve the initial-value problem.

dy dt

4 t^3 y 1 + t^4

dy y

4 t^3 1 + t^4

dt,

log y = log(1 + t^4 ) + C 1 , y = C(1 + t^4 ).

Thus, y(t) = C(1 + t^4 ), and using initial condition, we obtain y(0) = C = 1. Hence, the solution to the initial value problem is y(t) = 1 + t^4. X

It is always recommended to check if your solution (y(t) = 1 + t^4 ) is correct, i.e. whether it satisfies the initial value problem. Note that,

dy dt

=?^

4 t^3 y 1 + t^4

4 t^3 = 4 t^3 (1 + t^4 ) (1 + t^4 )

, X

and also, y(0) = 1. X

Section 5.2, Problem 1(b): Use Euler’s method to approximate the solution for the following initial-value problem:

y′^ = 1 + (t − y)^2 , 2 ≤ t ≤ 3 , y(2) = 1,

with h = 0.5.

Solution: We have f (t, y) = 1 + (t − y)^2. Since h = 0.5, ti = 2 + 0. 5 i. Given the initial condition w 0 = 1, Euler’s method calculates wi, i = 0, 1 , 2 ,.. .:

wi+1 = wi + hf (ti, wi) = wi + h(1 + (ti − wi)^2 ) = wi + 0.5(1 + (2 + 0. 5 i − wi)^2 ).

So,

w 1 = w 0 + 0.5(1 + (2 − w 0 )^2 ) = 1 + 0.5(1 + (2 − 1)^2 ) = 2. 0 , w 2 = w 1 + 0.5(1 + (2 + 0. 5 − w 1 )^2 ) = 2 + 0.5(1 + (2 + 0. 5 − 2)^2 ) = 2. 625.

Section 5.2, Problem 1(c): Use Euler’s method to approximate the solution for the following initial-value problem:

y′^ = 1 + y/t, 1 ≤ t ≤ 2 , y(1) = 2,

with h = 0.25.

Solution: We have f (t, y) = 1 + y/t. Since h = 0.25, ti = 1 + 0. 25 i, w 0 = 2. We have

wi+1 = wi + hf (ti, wi) = wi + 0.25(1 + wi/ti) = wi + 0.25(1 + wi/(1 + 0. 25 i)).

So,

w 1 = w 0 + 0.25(1 + w 0 ) = 2 + 0.25(3) = 2. 75 , w 2 = w 1 + 0.25(1 + w 1 /(1 + 0.25)) = 2.75 + 0.25(1 + 2. 75 / 1 .25) = 3. 55 ,

and, similarly, calculate w 3 and w 4.

Section 5.2, Problem 12: Consider the initial-value problem:

y′^ = − 10 y 0 ≤ t ≤ 2 , y(0) = 1,

which has solution y(t) = e−^10 t. What happens when Euler’s method is applied to this problem with h = 0.1? Does this behavior violate Theorem 5.9?

Solution: Using Euler’s method, we get:

wi+1 = wi + hf (ti, wi) = wi + 0. 1 · (− 10 wi) = wi − wi = 0, for all i.

We can also run the program to get the following results:

after the first step (t = 0.1): N = 1, h = 0. 10 , t = 0. 10 , w = 0. 0000000000 e + 000, y = 3. 6787944117 e − 001 , E =

  1. 6787944117 e − 001;

after 20 steps (t = 2): N = 20, h = 0. 10 , t = 2. 00 , w = 0. 0000000000 e + 000, y = 2. 0611536224 e − 009 , E =

  1. 0611536224 e − 009.

Theorem 5.9 gives the following estimate:

|y(ti) − wi| ≤ hM 2 L

[

eL(ti−a)^ − 1

]

For our problem, h = 0.1, |y′′(t)| = | 100 e−^10 t| ≤ 100 = M ,

∣ ∂f∂y (t, y)

∣ = | − 10 | = 10 = L,

a = 0. We now see if the estimate holds. After the first step, we have

| 0. 369 − 0 | ≤

[

e^10 ·(0.^1 −0)^ − 1

]

= 0. 859. X

After the final step, we have

| 2. 06 · 10 −^9 − 0 | ≤

[

e^10 ·(2−0)^ − 1

]

= 2. 43 · 108. X

Thus, even though we obtain an incorrect solution, this behavior does not violate the theorem.

Section 5.2, Problem 15: Let

E(h) = hM 2

δ h

a) For the initial-value problem

y′^ = −y + 1, 0 ≤ t ≤ 1 , y(0) = 0,

compute the value of h to minimize E(h). Assume δ = 5 · 10 −(n+1)^ if you will be using n-digit arithmetic in part (c).

b) For the optimal h computed in part (a), use the following equation

|y(ti) − ui| ≤

L

( (^) hM 2

δ h

)[

eL(ti−a)^ − 1

]

  • |δ 0 |eL(ti−a)^ (2)

to compute the minimal error obtainable.

c) Compare the actual error obtained using h = 0.1 and h = 0.01 to the minimal er- ror in part (b).

Solution: a) In order to find the minimum of E(h), we find E′(h) and set it to equal 0:

E′(h) =

M

δ h^2

Therefore,

h =

2 δ M

In order to find M such that |y′′(t)| ≤ M , t ∈ [0, 1], we need to find the analytic solution of the initial-value problem (2). We have

dy dt

= −y + 1, ∫ dy −y + 1

dt,

− log(−y + 1) = t + C 1 , log

−y + 1

= t + C 1 , 1 −y + 1

= Cet,

y(t) = 1 −

Cet^

We now employ initial condition in order to find constant C:

y(0) = 1 −

C

Thus, C = 1, which gives y(t) = 1 −

et^

. We also have: y′(t) = e−t^ and y′′(t) = −e−t.

Hence, |y′′(t)| = | − e−t| ≤ 1 if 0 ≤ t ≤ 1, which gives M = 1. We can calculate h now:

h =

2 δ M

2 · 5 · 10 −(n+1) 1

2 · 5 · 10 −(n+1)^ =

10 −n^ = 10−n/^2. X