Docsity

Applied Numerical Methods - Assignment 6 Solutions | MATH 151A, Assignments of Mathematics

Toggle sidebar
bg1
Homework 6 Solutions
Igor Yanovsky (Math 151B TA)
Section 11.4, Problem 1: For the boundary-value problem
y00 =−(y0)2−y+ log x,
1≤x≤2,
y(1) = 0, y(2) = log 2,
(1)
write the nonlinear system and formulas for Newton’s method.
Solution: We divide [1,2] into N+ 1 subintervals whose endpoints are xi= 1 + ih, for
i= 0,1, . . . , N + 1, and consider the discretization of the boundary-value problem in (1):
y00(xi) = −(y(xi)0)2−y(xi) + log xi.(2)
Replacing y00(xi) and y0(xi) by appropriate centered difference formulas, equation (2)
becomes:
y(xi+1)−2y(xi) + y(xi−1)
h2−h2
12y(4)(ξi) = −µy(xi+1)−y(xi−1)
2h−h2
6y000(ηi)2
−y(xi) + log xi,
for some ξiand ηiin the interval (xi−1,xi+1 ).
The difference method results when the error terms are deleted and the boundary condi-
tions are employed:
w0= 0, wN+1 = log 2,
and
−wi+1 −2wi+wi−1
h2−µwi+1 −wi−1
2h2
−wi+ log xi= 0,(3)
for each i= 1,2, . . . , N. Multiplying (3) by h2, we obtain
−wi+1 + 2wi−wi−1−µwi+1 −wi−1
22
−h2wi+h2log xi= 0,
which can be written as:
−wi+1 + 2wi−wi−1−µwi+1 −wi−1
22
−h2wi+h2log xi= 0,
or
−wi−1+ 2wi−wi+1 −1
4¡w2
i−1−2wi−1wi+1 +w2
i+1¢−h2wi+h2log xi= 0.
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

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

Homework 6 Solutions

Igor Yanovsky (Math 151B TA)

Section 11.4, Problem 1: For the boundary-value problem

y

′′ = −(y

′ )

2 − y + log x,

1 ≤ x ≤ 2 ,

y(1) = 0, y(2) = log 2,

write the nonlinear system and formulas for Newton’s method.

Solution: We divide [1, 2] into N + 1 subintervals whose endpoints are xi = 1 + ih, for

i = 0, 1 ,... , N + 1, and consider the discretization of the boundary-value problem in (1):

y

′′ (xi) = −(y(xi)

′ )

2 − y(xi) + log xi. (2)

Replacing y

′′ (xi) and y

′ (xi) by appropriate centered difference formulas, equation (2)

becomes:

y(xi+1) − 2 y(xi) + y(xi− 1 )

h^2

h

2

y

(4) (ξi) = −

y(xi+1) − y(xi− 1 )

2 h

h

2

y

′′′ (ηi)

−y(xi) + log xi,

for some ξi and ηi in the interval (xi− 1 , xi+1).

The difference method results when the error terms are deleted and the boundary condi-

tions are employed:

w 0 = 0, wN +1 = log 2,

and

wi+1 − 2 wi + wi− 1

h

2

wi+1 − wi− 1

2 h

− wi + log xi = 0, (3)

for each i = 1, 2 ,... , N. Multiplying (3) by h

2 , we obtain

−wi+1 + 2wi − wi− 1 −

wi+1 − wi− 1

− h

2 wi + h

2 log xi = 0,

which can be written as:

−wi+1 + 2wi − wi− 1 −

wi+1 − wi− 1

− h

2 wi + h

2 log xi = 0,

or

−wi− 1 + 2wi − wi+1 −

w

2 i− 1 −^2 wi−^1 wi+1^ +^ w

2 i+

− h

2 wi + h

2 log xi = 0.

Thus, the N × N nonlinear system is:

−0 + 2w 1 − w 2 −

2 − 2 · 0 · w 2 + w

2 2

− h

2 w 1 + h

2 log x 1 = 0 ,

−w 1 + 2w 2 − w 3 −

w

2 1 −^2 w^1 w^3 +^ w

2 3

− h

2 w 2 + h

2 log x 2 = 0 ,

−w 2 + 2w 3 − w 4 −

w

2 2 −^2 w^2 w^4 +^ w

2 4

− h

2 w 3 + h

2 log x 3 = 0 ,

−wN − 2 + 2wN − 1 − wN −

w

2 N − 2 −^2 wN^ −^2 wN^ +^ w

2 N

− h

2 wN − 1 + h

2 log xN − 1 = 0 ,

−wN − 1 + 2wN − log 2 −

w

2 N − 1 −^2 wN^ −^1 log 2 + (log 2)

2

− h

2 wN + h

2 log xN = 0 ,

where we designate the left-hand side of the first equation as F 1 (w 1 ,... , wN ), the second

equation as F 2 (w 1 ,... , wN ),.. ., the last equation as FN (w 1 ,... , wN ). Also, we designate

F^ ~ = (F 1 ,... , FN )

T and w~ = (w 1 ,... , wN )

T .

We use Newton’s method for nonlinear systems to approximate the solution to the

system F~ ( w~) = 0 above. A sequence of iterates w~

(k) = (w

(k) 1 , w

(k) 2 ,... , w

(k) N )

T is generated

that converges to the solution of this system. The Jacobian matrix J for this system is

J(w 1 ,... , wN ) =

∂F 1

∂w 1

∂F 1

∂w 2

∂F 1

∂w 3

∂F 1

∂wN

∂F 2

∂w 1

∂F 2

∂w 2

∂F 2

∂w 3

∂F 2

∂wN . . .

∂FN − 1

∂w 1

∂FN − 1

∂w 2

∂FN − 1

∂w 3

∂FN − 1

∂wN

∂FN

∂w 1

∂FN

∂w 2

∂FN

∂w 3

∂FN

∂wN

2 − h

2 −1 +

1 2

1 2

w 2 0 · · · 0

1 2

w 1 +

1 2

w 3 2 − h

2 −1 +

1 2

w 1 −

1 2

w 3

2

wN − 2 +

1 2

wN 2 − h

2 −1 +

1 2

wN − 2 −

1 2

wN

0 0 0 · · · 2 − h

2

We can now use the Netwon’s method for nonlinear systems

w ~

(k) = w~

(k−1) − J

− 1

w~

(k−1)

F~

w~

(k−1)

Section 7.1, Problem 2(c): Prove that for all x ∈ R

n , ||x|| 1 ≥ ||x|| 2.

Solution: Let x = (x 1 , x 2 ,... , xn)

T , and note that

|x 1 | + |x 2 | +... + |xn|

≥ x

2 1 +^ x

2 2 +^...^ +^ x

2 n,

or

( (^) n ∑

i=

|xi|

∑^ n

i=

x

2 i ,

or

∑^ n

i=

|xi| ≥

( (^) n ∑

i=

x

2 i

2 ,

which means that ||x|| 1 ≥ ||x|| 2.

Section 7.1, Problem 4(c): Find || · ||∞ for the following matrix:

A =

Solution: We have

||A||∞ = max 1 ≤i≤n

∑n

j=

|aij |.

Since

n ∑

j=

|a 1 j | = |a 11 | + |a 12 | + |a 13 | = | 2 | + | − 1 | + | 0 | = 3,

n ∑

j=

|a 2 j | = |a 21 | + |a 22 | + |a 23 | = | − 1 | + | 2 | + | − 1 | = 4,

∑^ n

j=

|a 3 j | = |a 31 | + |a 32 | + |a 33 | = | 0 | + | − 1 | + | 2 | = 3,

we have ||A||∞ = max{ 3 , 4 , 3 } = 4.

Section 7.1, Problem 7: Show by example that || · ||~, defined by ||A||~ = max 1 ≤i,j≤n

|aij |,

does not define a matrix norm.

Solution: A function || · ||~ is a matrix norm only if it satisfies definition 7.8 on page 424.

Consider A =

[

]

and B =

[

]

. Then, AB =

[

]

. We have ||A||~ = 1,

||B||~ = 1, and ||AB||~ = 2, and thus, ||AB||~ ≥ ||A||~||B||~, which contradicts one of

the conditions for being a norm.

Section 7.1, Problem 9(a): The Frobenius norm (which is not a natural norm) is

defined for an n × n matrix A by

||A||F =

( (^) n ∑

i=

n ∑

j=

|aij |

2

2 .

Show that || · ||F is a matrix norm.

Solution: For all n × n matrices A and B and all real numbers α, we have:

(i)

||A||F =

( (^) n ∑

i=

n ∑

j=

|aij |

2

2 ≥ 0. X

(ii)

||A||F =

( (^) n ∑

i=

∑^ n

j=

|aij |

2

2 = 0 if and only if A is a 0 matrix. X

(iii)

||αA||

2 F =

∑^ n

i=

∑^ n

j=

|α aij |

2

∑^ n

i=

∑^ n

j=

|α|

2 |aij |

2 = |α|

2

∑^ n

i=

∑^ n

j=

|aij |

2 = |α|

2 ||A||

2 F.

⇒ ||αA||F = |α| ||A||F. X

(iv) Here, we will use Cauchy-Schwarz Inequality:

∑^ n

i=

xiyi ≤

( (^) ∑n

i=

x

2 i

2

( (^) ∑n

i=

y

2 i

2 .

||A + B||

2 F =

∑^ n

i=

∑^ n

j=

|aij + bij |

2

∑^ n

i=

∑^ n

j=

(|aij | + |bij |)

2

n ∑

i=

n ∑

j=

|aij |

2

  • 2|aij ||bij | + |bij |

2

n ∑

i=

n ∑

j=

|aij |

2

  • 2

n ∑

i=

n ∑

j=

|aij ||bij | +

n ∑

i=

n ∑

j=

|bij |

2 ≤ (Cauchy-Schwarz)

∑^ n

i=

∑^ n

j=

|aij |

2

  • 2

( (^) ∑n

i=

∑^ n

j=

|aij |

2

2

( (^) ∑n

i=

∑^ n

j=

|bij |

2

2

∑^ n

i=

∑^ n

j=

|bij |

2

( (^) ∑n

i=

∑^ n

j=

|aij |

2

2

( (^) ∑n

i=

∑^ n

j=

|bij |

2

2

||A||F + ||B||F

⇒ ||A + B||F ≤ ||A||F + ||B||F. X

(v) Note that

AB =

∑n

k=1 a^1 kbk^1

∑n

k=1 a^1 kbk^2 · · ·^ · · ·^

∑n

∑ k=1^ a^1 kbkn n k=1 a^2 kbk^1

∑n

k=1 a^2 kbk^2 · · ·^ · · ·^

∑n

k=1 a^2 kbkn . . .

∑n

k=

ankbk 1

∑n

k=

ankbk 2 · · ·

∑n

k=

ankbk,n− 1

∑n

k=

ankbkn

Section 7.1, Problem 9(c): For any matrix A, show that ||A|| 2 ≤ ||A||F ≤ n

1 / 2 ||A|| 2.

Solution: The definitions of || · ||F and || · || 2 norms are:

||A||F =

( (^) n ∑

i=

∑^ n

j=

|aij |

2

2 .

||A|| 2 = max ||x|| 2 =

||Ax|| 2.

Note, that Ax is a vector:

Ax =

∑n

∑j=1^ a^1 j^ xj n j=1 a^2 j^ xj . . . ∑n

j=

anj xj

Thus, we have

||Ax|| 2 =

( (^) n ∑

i=

( (^) ∑n

j=

aij xj

) 2 )^

1 2 .

∂ We first show that ||A|| 2 ≤ ||A||F.

For vector x, such that ||x|| 2 = 1, we have

||Ax||

2 2 =

∑^ n

i=

( (^) ∑n

j=

aij xj

≤ (Cauchy-Schwarz)

∑^ n

i=

(( n ∑

j=

a

2 ij

2

( (^) ∑n

j=

x

2 j

2

∑^ n

i=

(( n ∑

j=

a

2 ij

)( (^) ∑n

j=

x

2 j

n ∑

i=

( (^) ∑n

j=

a

2 ij

· ||x||

2 2

n ∑

i=

( (^) ∑n

j=

a

2 ij

∑^ n

i=

∑^ n

j=

a

2 ij

= ||A||

2 F.

We showed that, ||Ax|| 2 ≤ ||A||F for all x, such that ||x|| 2 = 1.

Thus, max ||x|| 2 =

||Ax|| 2 ≤ ||A||F , or ||A|| 2 ≤ ||A||F.

∑ We now show that ||A||F ≤ n

1 / 2 ||A|| 2.

Let xi =

n

for all 1 ≤ i ≤ n. Then,

||A|| 2 = max ||x|| 2 =

||Ax|| 2 =

∑^ n

i=

( (^) ∑n

j=

aij xj

∑^ n

i=

∑^ n

j=

a

2 ij

n

n

∑^ n

i=

∑^ n

j=

a

2 ij =

n

||A||F.

Thus, ||A||F ≤ n

1 / 2 ||A|| 2.

Section 7.3, Problem 2(c): Find the first two iterations of the Jacobi method for the

following linear system, using x

(0) = 0 :

4 x 1 + x 2 − x 3 + x 4 = − 2 ,

x 1 + 4x 2 − x 3 − x 4 = − 1 ,

−x 1 − x 2 + 5x 3 + x 4 = 0 ,

x 1 − x 2 + x 3 + 3x 4 = 1.

Solution: The linear system Ax = b given by

E 1 : 4 x 1 + x 2 − x 3 + x 4 = − 2 ,

E 2 : x 1 + 4x 2 − x 3 − x 4 = − 1 ,

E 3 : −x 1 − x 2 + 5x 3 + x 4 = 0 ,

E 4 : x 1 − x 2 + x 3 + 3x 4 = 1

has the unique solution x = (− 0. 75342 , 0. 041096 , − 0. 28082 , 0 .69178).

To convert Ax = b to the form x = T x + c, solve equation E 1 for x 1 , E 2 for x 2 , E 3 for

x 3 , E 4 for x 4 , to obtain

x 1 = −

1 4

x 2 +

1 4

x 3 −

1 4

x 4 −

1 2

x 2 = −

1 4

x 1 +

1 4

x 3 +

1 4

x 4 −

1 4

x 3 =

1 5

x 1 +

1 5

x 2 −

1 5

x 4 ,

x 4 = −

1 3 x^1 +^

1 3 x^2 −^

1 3 x^3 +^

1

Then Ax = b can be written in the form x = T x + c, with

T =

1 4

1 4 −^

1 4 −

1 4

1 4

1 4 1 5

1 5

1 5 −

1 3

1 3

1 3

and c =

1 2 −

1 4 0 1 3

For initial approximation, we let x

(0) = (0, 0 , 0 , 0)

T

. Then x

(1) is given by

x

(1) 1 =^ −^

1 4 x

(0) 2 +^

1 4 x

(0) 3 −^

1 4 x

(0) 4 −^

1 2 =^ −^0.^5 ,

x

(1) 2 =^ −^

1 4 x

(0) 1 +^

1 4 x

(0) 3 +^

1 4 x

(0) 4 −^

1 4 =^ −^0.^25 ,

x

(1) 3 =^

1 5

x

(0) 1 +^

1 5

x

(0) 2 −^

1 5

x

(0) 4 =^0 ,

x

(1) 4 =^ −^

1 3

x

(0) 1 +^

1 3

x

(0) 2 −^

1 3

x

(0) 3 +^

1 3

The next iterate, x

(2) , is given by

x

(2) 1 =^ −^

1 4

x

(1) 2 +^

1 4

x

(1) 3 −^

1 4

x

(1) 4 −^

1 2

x

(2) 2 =^ −^

1 4 x

(1) 1 +^

1 4 x

(1) 3 +^

1 4 x

(1) 4 −^

1 4 =^ −^0.^041667 ,

x

(2) 3

1 5

x

(1) 1

1 5

x

(1) 2

1 5

x

(1) 4

x

(2) 4 =^ −^

1 3

x

(1) 1 +^

1 3

x

(1) 2 −^

1 3

x

(1) 3 +^

1 3