Professional Documents
Culture Documents
Assignment 4 Numerical Computing BMAT1 2023 24
Assignment 4 Numerical Computing BMAT1 2023 24
Assignment 4 Numerical Computing BMAT1 2023 24
I
Assignment 4 — 2nd Semester 2023-2024
1. (8 points) (i) Write a Bisection(a) function in Octave which takes in a real number
√
a and finds an approximation to 3 a to within 10−4 using the bisection algorithm.
(ii) Write a function Dist(a, b) in Octave which uses Newton’s method to compute
the value of x0 (to within 10−4 ) which is the point on the graph of the parabola
y = x2 that is closest to (a, b) ∈ R2 . (If the answer is not unique, which answer
does your code prefer?) Compute the value Dist(1,0).
2. (8 points) In the bisection method, let M denote the length of the interval [a0 , b0 ]. Let
(x0 , x1 , x2 , . . . , ) represent the successive midpoints generated by the bisection method.
(ii) The bisection method can be used whenever f (a0 )f (b0 ) < 0. If f (x) has more
than one zero in ther interval, which zero does the bisection algorithm (discussed
in class) usually locate?
5. (8 points) For each of the following equations, determine an iteration function (and an
interval I) so that the conditions of the contraction mapping fixed-point theorem are
satisfied (assume that it is desired to find the smallest positive root):
(i) x3 − x − 1 = 0
(ii) x − tan x = 0
(iii) e−x − cos x = 0.
Write a function fixPt(f) which implements the fixed point iteration algorithm for a
function f . Use it to find the smallest positive root of the above three equations.
6. (8 points) (i) The equation ex − 4x2 = 0 has a root between x = 4 and x = 5. Show
that we cannot find this root using fixed point iteration with the “natural” iteration
x
function x = 21 e 2 . Find an iteration function which will actually find the root.
(ii) The equation ex − 4x2 = 0 also has a root between x = 0 and x = 1. Show that
x
the iteration function x = 21 e 2 will converge to the root if the initial value x0 is
chosen to be in the interval [0, 1].