Docsity

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

Toggle sidebar
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
n10
=1
n10
<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;