Tutorial 3 Lab 3
Tutorial 3 Lab 3
3. Use the Secant method to find solutions accurate to within 10−4 for the following
problems:
a. 𝑥 3 − 2𝑥 2 − 5 = 0, [1,4]
b. 𝑥 3 + 3𝑥 2 − 10 = 0, [−3, −2]
4. Use the false position method to find solutions accurate to within 10−4 for the
following problems:
𝜋
a. 𝑥 − cos(𝑥) = 0, [0, ]
2
Write a Matlab code to find a solution to f (x) = 0 given two initial approximations p0
and p1:
INPUT: initial approximations p0 and p1, TOL, Maximum number of iterations N0.
Step 1 Set i = 2;
q0 = f ( p0);
q1 = f ( p1).
STOP.
Step 5 Set i = i + 1.
q0 = q1;
p1 = p;
Step 7 OUTPUT (‘The method failed after N0 iterations, N0 =’, N0); (The procedure
was unsuccessful.)
STOP.
2. False Position
To find a solution to f (x) = 0 given the continuous function f on the interval [ p0, p1]
INPUT initial approximations p0, p1; tolerance TOL; maximum number of iterations
N0.
Step 1 Set i = 2;
q0 = f ( p0);
q1 = f ( p1).
STOP.
Step 5 Set i = i + 1;
q = f ( p).
Step 7 Set p1 = p;
q1 = q.
STOP.