Docsity

Practice Questions for Assignment 1 - 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 1
This assignment is due in class on Thursday, July 8. The exercises are from the textbook, Nu-
merical Analysis, 7th Edition, by Burden and Faires. Note: These exercises have been modified to
indicate tasks that must be performed using MATLAB. For other exercises, you may use MATLAB
if you wish.
For all exercises, you must show your work to receive full credit. For exercises involving MAT-
LAB, you must submit your code and your output.
Section 1.1
5. Use the Intermediate Value Theorem and Rolle’s Theorem to show that the graph of f(x) =
x3+ 2x+kcrosses the x-axis exactly once, regardless of the value of the constant k.
9. Find the second Taylor polynomial P2(x) for the function f(x) = excos xabout x0= 0.
(a) Use P2(0.5) to approximate f(0.5). Find an upper bound on the error |f(0.5) −P2(0.5)|
using the error formula, and compare it to the actual error.
(b) Find a bound for the error |f(x)−P2(x)|in using P2(x) to approximate f(x) on the
interval [0,1].
(c) Approximate R1
0f(x)dx using R1
0P2(x)dx.
(d) Find an upper bound for the error in (c) by finding an upper bound for R1
0|R2(x)|dx,
and compare the bound to the actual error.
15. Write an algorithm that accepts a real number xand a nonnegative integer nand computes
an approximation to cos xusing the nth Taylor polynomial Pn(x) with center x0=π/4.
Implement your algorithm using MATLAB and approximate cos 42◦to an accuracy of 10−6.
19. Modify your algorithm from Exercise 15 so that it computes an approximation to exusing
Pn(x) with center x0= 0. Find a value of nnecessary for Pn(x) to approximate exto within
10−6on [0,0.5]. Using MATLAB, show that with this value of n, your algorithm approximates
exto this degree of accuracy at x= 0.25.
21. The polynomial P2(x) = 1 −1
2x2is to be used to approximate f(x) = cos xin [−1
2,1
2]. Find
a bound for the maximum error.
25. A function f: [a, b]→Ris said to satisfy a Lipschitz condition with Lipschitz constant Lon
[a, b] if, for every x,y∈[a, b], we have |f(x)−f(y)| ≤ L|x−y|.
1
pf3
pf4
pf5

Partial preview of the text

Download Practice Questions for Assignment 1 - 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 1

This assignment is due in class on Thursday, July 8. The exercises are from the textbook, Nu- merical Analysis, 7th Edition, by Burden and Faires. Note: These exercises have been modified to indicate tasks that must be performed using MATLAB. For other exercises, you may use MATLAB if you wish. For all exercises, you must show your work to receive full credit. For exercises involving MAT- LAB, you must submit your code and your output.

Section 1.

  1. Use the Intermediate Value Theorem and Rolle’s Theorem to show that the graph of f (x) = x^3 + 2x + k crosses the x-axis exactly once, regardless of the value of the constant k.
  2. Find the second Taylor polynomial P 2 (x) for the function f (x) = ex^ cos x about x 0 = 0.

(a) Use P 2 (0.5) to approximate f (0.5). Find an upper bound on the error |f (0.5) − P 2 (0.5)| using the error formula, and compare it to the actual error. (b) Find a bound for the error |f (x) − P 2 (x)| in using P 2 (x) to approximate f (x) on the interval [0, 1]. (c) Approximate

0 f^ (x)^ dx^ using^

0 P^2 (x)^ dx. (d) Find an upper bound for the error in (c) by finding an upper bound for

0 |R^2 (x)|^ dx, and compare the bound to the actual error.

  1. Write an algorithm that accepts a real number x and a nonnegative integer n and computes an approximation to cos x using the nth Taylor polynomial Pn(x) with center x 0 = π/4. Implement your algorithm using MATLAB and approximate cos 42◦^ to an accuracy of 10−^6.
  2. Modify your algorithm from Exercise 15 so that it computes an approximation to ex^ using Pn(x) with center x 0 = 0. Find a value of n necessary for Pn(x) to approximate ex^ to within 10 −^6 on [0, 0 .5]. Using MATLAB, show that with this value of n, your algorithm approximates ex^ to this degree of accuracy at x = 0.25.
  3. The polynomial P 2 (x) = 1 − 12 x^2 is to be used to approximate f (x) = cos x in [− 12 , 12 ]. Find a bound for the maximum error.
  4. A function f : [a, b] → R is said to satisfy a Lipschitz condition with Lipschitz constant L on [a, b] if, for every x, y ∈ [a, b], we have |f (x) − f (y)| ≤ L|x − y|.

(a) Show that if f satisfies a Lipschitz condition with Lipschitz constant L on an interval [a, b], then f ∈ C[a, b], where C[a, b] is the space of functions that are continuous on [a, b]. (b) Show that if f has a derivative that is bounded on [a, b] by L, then f satisfies a Lipschitz condition with Lipschitz constant L on [a, b]. (c) Give an example of a function that is continuous on a closed interval but does not satisfy a Lipschitz condition on the interval. Hint: what can be said about the derivative of such a function?

Section 1.

  1. Suppose p∗^ must approximate p with relative error at most 10−^3. Find the largest interval in which p∗^ must lie for each value of p.

(a) 150 (b) 900 (c) 1500 (d) 90

  1. Use three-digit rounding arithmetic to perform the following calculations. Compute the ab- solute error and relative error with the exact value determined to at least five digits.

(a) 133 + 0. 921 (b) 133 − 0. 499 (c) (121 − 0 .327) − 119 (d) (121 − 119) − 0. 327 (e)

(^1314) − (^67) 2 e− 5. 4 (f) − 10 π + 6e − 623 (g)

9

7

(h) π−^

(^227) 1 17

  1. The first three nonzero terms of the Maclaurin series for the arctangent function are x − (1/3)x^3 + (1/5)x^5. Compute the absolute error and relative error in the following approxi- mations of π using the polynomial in place of the arctangent:

(a) 4

[

arctan

2

  • arctan

3

)]

(b) 16 arctan

5

− 4 arctan

239

Implement this algorithm using MATLAB and solve the following linear systems.

(a)

  1. 130 x − 6. 990 y = 14. 20
  2. 110 x + 12. 20 y = − 0. 1370

(b)

  1. 013 x − 6. 099 y = 14. 22 − 18. 11 x + 112. 2 y = − 0. 1376

  2. The binomial coefficient (^) ( m k

m! k!(m − k)! describes the number of ways of choosing a subset of k objects from a set of m elements.

(a) Suppose decimal machine numbers are of the form

± 0 .d 1 d 2 d 3 d 4 × 10 n, 1 ≤ d 1 ≤ 9 , 0 ≤ di ≤ 9 , i = 2, 3 , 4 , |n| ≤ 15.

What is the largest value of m for which the binomial coefficient

m k

can be computed for all k by the definition without causing overflow?

(b) Show that

m k

can also be computed by

( m k

( (^) m k

) (^ m − 1 k − 1

m − k + 1 1

(c) What is the largest value of m for which the binomial coefficient

m 3

can be computed by the formula in part (b) without causing overflow? (d) Use the equation in part (b) and four-digit chopping arithmetic to compute the number of possible 5-card hands in a 52-card deck. Compute the actual and relative errors.

Section 1.

  1. (a) Use three-digit chopping arithmetic to compute the sum

i=1(1/i

(^2) ) first by 1 1 +^

1 4 + · · · + 1001 and then by 1001 + 811 + · · · + 11. Which method is more accurate, and why?

(b) Write an algorithm to sum the finite series

∑N

i=1(1/i (^2) ) in reverse order. Implement your algorithm using MATLAB and run it with N = 10.

  1. The Maclaurin series for the arctangent function converges for − 1 < x ≤ 1 and is given by

arctan x = lim n→∞ Pn(x) = lim n→∞

∑^ n

i=

(−1)i+^ x^2 i−^1 2 i − 1

(a) Use the fact that tan π/4 = 1 to determine the number n of terms of the series that need to be summed to ensure that | 4 Pn(1) − π| < 10 −^3. (b) The C++ programming language requires the value of π to be within 10−^10. How many terms of the series would we need to sum to obtain this degree of accuracy?

  1. Another formula for computing π can be deduced from the identity π/4 = 4 arctan 15 − arctan 2391. Write an algorithm to compute an approximation to π that uses this formula and the series for arctan x from Exercise 3. Implement your algorithm using MATLAB and determine the number of terms that must be summed to ensure an approximation to π within 10 −^3.
  2. Find the rates of convergence of the following functions as h → 0. (a) limh→ 0 sinh^ h= 1 (b) limh→ 0 1 −cosh h= 0 (c) limh→ 0 sin^ h−hh cos^ h= 0 (d) limh→ 0 1 −e h h =^ −^1
  3. (a) Suppose that 0 < q < p and that αn = α + O(n−p). Show that αn = α + O(n−q).

(b) Make a table listing 1/n, 1/n^2 , 1/n^3 , and 1/n^4 for n = 5, 10 , 100, and 1000, and discuss the varying rates of convergence of these sequences as n becomes large.

  1. Suppose that as x approaches zero,

F 1 (x) = L 1 + O(xα) and F 2 (x) = L 2 + O(xβ^ ).

Let c 1 and c 2 be nonzero constants, and define

F (x) = c 1 F 1 (x) + c 2 F 2 (x) and G(x) = F 1 (c 1 x) + F 2 (c 2 x).

Show that if γ = min{α, β}, then as x approaches zero, (a) F (x) = c 1 L 1 + c 2 L 2 + O(xγ^ ) (b) G(x) = L 1 + L 2 + O(xγ^ )