0% found this document useful (0 votes)
11 views6 pages

MA128ASampleMidterm2024 Solution

Uploaded by

hangyuju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

MA128ASampleMidterm2024 Solution

Uploaded by

hangyuju
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Prof.

Ming Gu, 861 Evans, tel: 2-3145


Email: [email protected]

Math128A: Numerical Analysis


Sample Midterm

This is a closed book exam. You are allowed to cite any results,
up to Section 4.5 but excluding those in the exercises, from the
textbook. Results from anywhere else will be treated the same
as your answers, which need to be justified. Completely correct
answers given without justification will receive little credit. Partial
solutions will get partial credit.

Problem Maximum Score Your Score

1 20

2 20

3 20

4 20

5 20

Total 100
Math128A: Numerical Analysis Sample Midterm 2

1. Determine the absolute error, the relative error, and the number of
significant digits in the approximation

π ≈ 3.14

Solution:

(a) the absolute error is

π − 3.14 ≈ 0.00159 · · ·

(b) the relative error is

|π − 3.14| 0.00159 · · ·

π π

(c) the relative error is

|π − 3.14|
5.0 × 10−4 < ≈ 5.07 × 10−4
π
thus the number of significant digits is 3.
Math128A: Numerical Analysis Sample Midterm 3

2. Let x0 < x1 < x2 . Find a second degree polynomial P (x) such that

P (x0 ) = f0 , P (x1 ) = f1 , and P ′ (x2 ) = f2′ .

Solution: Write P (x) as

P (x) = α + β(x − x0 ) + γ(x − x0 )(x − x1 )

The condition
P (x0 ) = f0 leads to α = f0 .
The condition
f1 − f0
P (x1 ) = f1 leads to β = .
x 1 − x0
Finally, since
P ′ (x) = β + γ(2 x − x0 − x1 )
The condition
f2′ − β
P ′ (x2 ) = f2′ leads to γ =
2 x2 − x0 − x1
Math128A: Numerical Analysis Sample Midterm 4

3. Show that the cubic equation

2x3 − 6x + 1 = 0 (1)

has a real root in the interval [0, 1/2]. Perform one step of Bisection
method with this interval.

Solution: Let
f (x) = 2x3 − 6x + 1
Since f (0) = 1 > 0 and f (1/2) = −1.75 < 0, it follows from interme-
diate value theorem that there must be a c ∈ [0, 1/2] so that f (c) = 0.
To perform one step of Bisection method with this interval, let
1 1
p= (0 + 1/2) =
2 4
Since
2 6
f (p) = 3
− + 1 < 0,
4 4
it follows that there is a root in [0, 1/4].
Math128A: Numerical Analysis Sample Midterm 5

4. Reformulate the above equation (1) as

2x3 + 1
x= .
6
Define the fixed point iteration (FPI) based on this equation, and show
that FPI convergences for any initial guess in [0, 1/2].

Solution: The fixed point iteration is

2x3k + 1
xk+1 =
6
for k = 0, 1, · · · , with a given x0 . Define

2x3 + 1
g(x) =
6
For FPI to converge for any initial guess in [0, 1/2], we need to prove

(a) g(x) ∈ [0, 1/2] for any x ∈ [0, 1/2]


(b) there exists a 0 < κ < 1 so that |g ′ (x)| ≤ κ for any x ∈ [0, 1/2]

Indeed, g ′ (x) = x2 ≥ 0 for any x ∈ [0, 1/2],

(a) therefore g(x) monotonically increases in [0, 1/2], with


1 1
g(0) = ∈ [0, 1/2], g(1/2) < ∈ [0, 1/2]
6 2
and hence g(x) ∈ [0, 1/2] for any x ∈ [0, 1/2]
1
(b) Let κ = 4
< 1, then for any x ∈ [0, 1/2],

|g ′ (x)| = x2 ≤ κ
Math128A: Numerical Analysis Sample Midterm 6

5. Construct the natural cubic spline that approximates


sin x
f (x) =
x
at the nodes −1, 0, 1. Note that at x = 0, we define f (0) = 1.

Solution: Parameterize S as
(
a0 + b0 x + c0 x2 + d0 x3 , if x ∈ [−1, 0],
S(x) =
a1 + b1 x + c1 x2 + d1 x3 , if x ∈ [0, 1].

The condition that S(x) ∈ C 2 [−1, 1] implies that


S(x) |x=0− = S(x) |x=0+ , S(x)′ |x=0− = S(x)′ |x=0+ , S(x)′′ |x=0− = S(x)′′ |x=0+

which leads to

a0 = a1 = f (0) = 1, b0 = b1 , c0 = c1

Additionally, the natural cubic spline condition implies that

S(x)′′ |x=−1+ = 2 c0 − 6 d 0 = 0
S(x)′′ |x=1− = 2 c0 + 6 d 1 = 0

which implies
c0 c0
d0 = , d1 = −
3 3
Putting it all together,
(
c0
1 + b0 x + c 0 x 2 + 3
x3 , if x ∈ [−1, 0],
S(x) = c0
1 + b0 x + c 0 x 2 − 3
x3 , if x ∈ [0, 1].

Finally, the conditions

S(−1) = S(1) = sin 1

leads to conditions
c0
1 − b0 + c 0 − = sin 1
3
c0
1 + b0 + c 0 − = sin 1
3
which has solution
3
b0 = 0, c0 = − (1 − sin 1)
2
and
3 x2
!
|x|
S(x) = 1 − (1 − sin 1) 1 −
2 3

You might also like