MATH 170B辅导、辅导Python,Java程序
HOMEWORK 3 SOLUTIONS (MATH 170B, WINTER 2022)
DUE DATE: SEE CANVAS
REVISION NUMBER: 3.0
SUBMITTING HOMEWORK ON GRADESCOPE: For non-computer problems, create a PDF file of your work by whatever means you prefer
(scanning handwritten work with your phone, or using LaTeX to typeset your mathematics, either is fine), and upload that PDF to Gradescope. For
computer problems, take a screen shot of both your MATLAB functions (the code you write) and the output they produce, and upload that PDF to
Gradescope.
OUR HOMEWORK RULES ALWAYS APPLY: As discussed in detail on the syllabus, you are allowed (encouraged) to discuss homework
problems with other students in our class, but you must write up your own solutions yourself. You are not allowed to post these questions, or their
solutions, on homework help websites (such as Chegg.com) or other websites.
[Q1] (Section 6.4: Problem 6.4.7)
(a) Determine all the values of a, b, c, d, e for which the following function is a cubic
spline:
fpxq “
$&% apx′ 2q
2 ` bpx′ 1q3, x P p′8, 1s
cpx′ 2q2, x P r1, 3s
dpx′ 2q2 ` epx′ 3q3, x P r3,8s.
(b) Determine the values of the parameters so that the cubic spline interpolates this data:
x 0 1 4
y 26 7 25
(Hint: Just impose all the spline conditions.)
Solution:
(a) Denote S0pxq “ apx′2q2`bpx′1q3, S1pxq “ cpx′2q2, S2pxq “ dpx′2q2`epx′3q3.
Enforce
Si′1ptiq “ Siptiq, S 1i′1ptiq “ S 1iptiq and S2i′1ptiq “ S2i ptiq
for points t1 “ 1, t2 “ 3 and i “ 1, 2.
Then we obtain the result a “ c “ d. For any a “ c “ d and arbitrary values of b, e,
the function f is a cubic spline.
(b) Add the equations of interpolation fp0q “ 26, fp1q “ 7, fp4q “ 25, we have
4a` b “ 26
a “ c “ d “ 7
4d` e “ 25
Solve the above system we get the answer a “ 7, b “ ′2, c “ 7, d “ 7, e “ ′3.
1
2 REFERENCES
[Q2] (Section 6.4: Problem 6.4.11)
(a) Determine the values of a, b, c so this is a cubic spline having knots 0, 1, 2:
fpxq “
"
3` x′ 9x2, x P r0, 1s
a` bpx′ 1q ` cpx′ 1q2 ` dpx′ 1q3, x P r1, 2s
(b) Determine d so that
?2
0
rf2pxqs2 dx is minimized.
(c) Find d so that f2p2q “ 0; why is d different from d in part (b)?
(Hint: The first part is just applying the spline conditions; the second part is first-quarter calculus,
and the last part is again appling a spline condition.)
Solution:
(a) Denote
S0pxq “ 3` x′ 9x2
S1pxq “ a` bpx′ 1q ` cpx′ 1q2 ` dpx′ 1q3.
Then
S 10pxq “ 1′ 18x S20pxq “ ′18
S 11pxq “ b` 2cpx′ 1q ` 3dpx′ 1q2 S21pxq “ 2c` 6dpx′ 1q
For f to be a cubic spline, we must have
S0p1q “ S1p1q ù? ′5 “ a
and
S 10p1q “ S 11p1q ù? ′17 “ b
and
S20p1q “ S21p1q ù? ′18 “ 2c ù? ′9 “ c.
So f is a cubic spline when a “ ′5 , b “ ′17 , c “ ′9 , and d is any real number.
(b) First, calculate? 2
HOMEWORK 1 SOLUTIONS (MATH 170B, WINTER 2022)
DUE DATE: SEE CANVAS
REVISION NUMBER: 1.0
INSTRUCTOR: Prof. Michael Holst
BOOKS:
[1] D. Kincaid and W. Cheney. Numerical Analysis: Mathematics of Scientific Computing. Third. Providence, RI: American Mathematical
Society, 2017.
MATERIAL COVERED BY HOMEWORK 1: This homework covers mainly material from lectures in weeks one and two, covering roughly
the following sections of [1]: 1.1, 1.2, 3.1, 3.2, 3.3, 3.4, 3.6.
SUBMITTING HOMEWORK ON GRADESCOPE: For non-computer problems, create a PDF file of your work by whatever means you prefer
(scanning handwritten work with your phone, or using LaTeX to typeset your mathematics, either is fine), and upload that PDF to Gradescope. For
computer problems, take a screen shot of both your MATLAB functions (the code you write) and the output they produce, and upload that PDF to
Gradescope.
OUR HOMEWORK RULES ALWAYS APPLY: As discussed in detail on the syllabus, you are allowed (encouraged) to discuss homework
problems with other students in our class, but you must write up your own solutions yourself. You are not allowed to post these questions, or their
solutions, on homework help websites (such as Chegg.com) or other websites.
[Q1] (Section 1.1/1.2: Review: Taylor’s Theorem and Related; Similar to Exercise 1.1.5)
Let fpxq “ cospxq.
(1) Derive the Taylor series for fpxq at x “ 0. (Use summation notation.)
(2) Write down the Taylor remainder for the series when truncating the series at n terms.
(3) Find the min number of terms needed to compute fp1q with error ? 10′4.
(Hint: This is all in Section 1.1, and in your Calculus book from your first quarter of calculus.)
Solution:
(1) f 1pxq “ ′sinx, f 2pxq “ ′cosx, f p3qpxq “ sinx, f p4qpxq “ cosx.
so fpxq “ 1′ x2