Docsity

Homework Assignment 3 Hints - Numerical Analysis | Math 105, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Jim Lambers
Math 105A
Summer Session I 2003-04
Homework Assignment 3 Hints
Each homework assignment from the textbook will be accompanied by a handout like this one,
that contains hints about the exercises. As I receive questions on the assignment, this handout may
be updated with additional information. When this occurs, this will be indicated on the Updates
page of the site,
http://math.uci.edu/∼jlambers/math105a/updates.html
which you should be checking frequently.
Section 3.4
3. It is recommended that you write a function that accepts two arguments, vectors xand y,
that contain the given x-values x0, x1, . . . , xnand the y-values y0, y1, . . . , yn, respectively.
Then you can obtain the value of nusing the statement n=length(x)-1;, where the length
function returns the length of a vector.
Then, to use your function, you can simply construct vectors containing the data. For exam-
ple, in part (a), you can use the statements
>> x=[ 8.3 8.6 ];
>> y=[ 17.56592 18.50515 ];
and call your function with the arguments xand y. I’ve noticed that a lot of you write code
that prompts the user for data, using the input function. That’s not necessary unless you’re
writing an application that you expect someone else to use, which isn’t the case here.
21. (a) You can modify the code you wrote for Problem 3 to implement Algorithm 3.5 in the
text.
If, instead, you choose to compute the clamped spline by hand, you need to solve a
system of three equations for the three unknowns c0,c1and c2. Two of these equations
arise from the clamped boundary conditions:
h(2c0+c1)=3f0(x0)−
3
h(a1−a0),
h(cn−1+ 2cn) = 3
h(an−an−1)−3f0(xn),
1
pf3

Partial preview of the text

Download Homework Assignment 3 Hints - Numerical Analysis | Math 105 and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Jim Lambers Math 105A Summer Session I 2003- Homework Assignment 3 Hints

Each homework assignment from the textbook will be accompanied by a handout like this one, that contains hints about the exercises. As I receive questions on the assignment, this handout may be updated with additional information. When this occurs, this will be indicated on the Updates page of the site,

http://math.uci.edu/∼jlambers/math105a/updates.html

which you should be checking frequently.

Section 3.

  1. It is recommended that you write a function that accepts two arguments, vectors x and y, that contain the given x-values x 0 , x 1 ,... , xn and the y-values y 0 , y 1 ,... , yn, respectively. Then you can obtain the value of n using the statement n=length(x)-1;, where the length function returns the length of a vector. Then, to use your function, you can simply construct vectors containing the data. For exam- ple, in part (a), you can use the statements

x=[ 8.3 8.6 ]; y=[ 17.56592 18.50515 ];

and call your function with the arguments x and y. I’ve noticed that a lot of you write code that prompts the user for data, using the input function. That’s not necessary unless you’re writing an application that you expect someone else to use, which isn’t the case here.

  1. (a) You can modify the code you wrote for Problem 3 to implement Algorithm 3.5 in the text. If, instead, you choose to compute the clamped spline by hand, you need to solve a system of three equations for the three unknowns c 0 , c 1 and c 2. Two of these equations arise from the clamped boundary conditions:

h(2c 0 + c 1 ) = 3 f ′(x 0 ) −

h

(a 1 − a 0 ),

h(cn− 1 + 2cn) =

h (an − an− 1 ) − 3 f ′(xn),

where h is the spacing between the interpolation points x 0 , x 1 and x 2 , which are equally spaced in this problem. The third equation comes from the fact that for clamped splines and natural splines, the coefficients c 0 , c 1 ,... , cn satisfy the equations

h(cj + 4cj+1 + cj+2) =

h (aj+2 − 2 aj+1 + aj ), j = 0, 1 ,... , n − 2 ,

but since n = 2 in this problem, there is only one equation of this form. (b) To integrate each piece of the spline, you can use the powerform function posted on the site to convert the polynomial into power form, and then use polyint to compute its antiderivative and polyval to evaluate the antiderivative at the limits of integration. (c) The answer given in the back of the book is the bound for the error in the integral. (d) There is a typo in the answer in the back of the book. At the end of the answer, it should read: S(0.02) = 1.041139 and s(0.02) = 1.040811.

Section 4.

  1. To determine the “most accurate” three-point formula, use the error terms. These terms can be found in the Lecture 11 Notes and in the text. How do these error terms differ, and how do these differences influence the size of the error? In part (a), there is a typo in one of the answers in the back of the book. The value of f ′(1.4) is − 32 .510850, not − 32 .150850.

Section 4.

  1. This problem is very similar to one of the Lecture 13 examples.
  2. (a) (b) (c) If the assumption about the error was not valid, then extrapolation would produce a grossly inaccurate result, because the denominator in the extrapolation formula would be wrong.

Section 4.

  1. Use the definition of degree given in the text and in the Lecture 12 Notes.