

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 3
This page cannot be seen from the preview
Don't miss anything!


Math 151A Homework #1 โ due Wednesday 10/11, in class
Show all your work!
Answer: The first stopping criterion requires that
|f (pn)| = |(pn โ 1)^10 | =
n
n
โ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.
โ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.
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;