Math 151A Homework #1: Stopping Criteria and Approximating Square Root of Two, Assignments of Mathematics

Solutions to math 151a homework #1 problems, focusing on the importance of stopping criteria and approximating the square root of two using the bisection method. It covers the analysis of the sequence {pn} and the calculation of the maximum number of iterations required to estimate the square root to within 10โˆ’4.

Typology: Assignments

Pre 2010

Uploaded on 08/26/2009

koofers-user-lds
koofers-user-lds ๐Ÿ‡บ๐Ÿ‡ธ

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Math 151A Homework #1 โ€“ due Wednesday 10/11, in class
Show all your work!
1. On the importance of stopping criteria. (section 2.1, problem 16)
Let f(x) = (xโˆ’1)10 (with a root at p= 1), and consider the sequence of approximations to
the root pgiven by pn= 1 + (1/n). Show the the stopping criterion |f(pn)|<10โˆ’3is met
for nโ‰ฅ2, but |pโˆ’pn|<10โˆ’3requires that n > 1000.
Answer:
The first stopping criterion requires that
|f(pn)|=|(pnโˆ’1)10|=๎˜Œ
๎˜Œ
๎˜Œ๎˜1
n๎˜‘10๎˜Œ
๎˜Œ
๎˜Œ=๎˜1
n๎˜‘10
<10โˆ’3
โˆ’10 log(n)<โˆ’3
n > 100.3โ‰ˆ1.995
which is satisfied when nโ‰ฅ2.
The second stopping criterion requires that
|pโˆ’pn|=|1/n|= 1/n < 10โˆ’3
which is satisfied when n > 103.
2. On the importance of stopping criteria, II. (section2.1, problem 17)
Let pnbe the sequence defined by pn=Pn
k=1(1/k). Show that pndiverges even though
limnโ†’โˆž(pnโˆ’pnโˆ’1) = 0.
Answer:
pnโˆ’pnโˆ’1=
n
X
k=1
๎˜1
k๎˜‘โˆ’
nโˆ’1
X
k=1
๎˜1
k๎˜‘
=1
n
So
lim
nโ†’โˆž
(pnโˆ’pnโˆ’1) = lim
nโ†’โˆž
1
n= 0
so the difference between consectutive terms vanishes. But {pn}is the well-known
harmonic series, which diverges.
3. The sqare root of two.
Use the bisection method to approximate the value of โˆš2, given that it lies in the interval
[1,2]. Do this in two parts:
a. Calculate the maximum number of iterations required to estimate โˆš2 to within 10โˆ’4,
starting with the interval [1,2].
pf3

Partial preview of the text

Download Math 151A Homework #1: Stopping Criteria and Approximating Square Root of Two and more Assignments Mathematics in PDF only on Docsity!

Math 151A Homework #1 โ€“ due Wednesday 10/11, in class

Show all your work!

  1. On the importance of stopping criteria. (section 2.1, problem 16) Let f (x) = (x โˆ’ 1)^10 (with a root at p = 1), and consider the sequence of approximations to the root p given by pn = 1 + (1/n). Show the the stopping criterion |f (pn)| < 10 โˆ’^3 is met for n โ‰ฅ 2, but |p โˆ’ pn| < 10 โˆ’^3 requires that n > 1000.

Answer: The first stopping criterion requires that

|f (pn)| = |(pn โˆ’ 1)^10 | =

n

n

< 10 โˆ’^3

โˆ’10 log(n) < โˆ’ 3 n > 100.^3 โ‰ˆ 1. 995

which is satisfied when n โ‰ฅ 2. The second stopping criterion requires that

|p โˆ’ pn| = | 1 /n| = 1/n < 10 โˆ’^3

which is satisfied when n > 103.

  1. On the importance of stopping criteria, II. (section2.1, problem 17) Let pn be the sequence defined by pn =

โˆ‘n k=1(1/k).^ Show that^ pn^ diverges even though limnโ†’โˆž(pn โˆ’ pnโˆ’ 1 ) = 0.

Answer:

pn โˆ’ pnโˆ’ 1 =

โˆ‘^ n

k=

k

โˆ‘^ nโˆ’^1

k=

k

n So

nlimโ†’โˆž(pn^ โˆ’^ pnโˆ’^1 ) = lim nโ†’โˆž

n

so the difference between consectutive terms vanishes. But {pn} is the well-known harmonic series, which diverges.

  1. The sqare root of two. Use the bisection method to approximate the value of

2, given that it lies in the interval [1, 2]. Do this in two parts:

a. Calculate the maximum number of iterations required to estimate

2 to within 10โˆ’^4 , starting with the interval [1, 2].

b. Use the bisection method to compute the value of

2 to within 10โˆ’^4. Print out and submit (along with your code) the intermediate approximations at each iteration.

[Hint: Consider f (x) = x^2 โˆ’ 2]

Answer: Part a. From theorem 2.1, we know that

|pn โˆ’ p| โ‰ค

b โˆ’ a 2 n^

when n โ‰ฅ 1. In this case, a = 1, b = 2, and we need an answer to within 10โˆ’^4. This means that

10 โˆ’^4 โ‰ค

2 n^

2 n โˆ’ 4 โ‰ค โˆ’n log(2) n โ‰ฅ

log(2)

To meet this, we require 14 iterations.

Part b. Create a function file called f.m containing: function f = f(x) f = x.^2 - 2; end

and script file called bisection.m containing, for example: %---------------------------------------------------------- % Matlab/Octave program to find the root of a function % - the function must be defined in f.m %----------------------------------------------------------

% set the endpoints a and b, and the desired precision a=1; b=2; tol = 1.0e-4;

% prevent infinite loops, by setting a maximum % number of iterations maxits = 1000;

for i = 1:maxits

% compute the midpoint p = (a+b)/2.0;