the last 2 algorithms are:
Secant Method:
INPUT: initial approximations p0, p1; tolerance TOL; maximum number of iterations N0.
OUTPUT: approximate solution p or message of failure
Step 1: Set i = 2;
q0 = f(p0);
q1 = f(p1);
Step 2: While i <= N0 do steps 3 6
Step 3: Set p = p1 q1(p1 p0)/(q1 q0). (Compute pi).
Step 4: If |p p1| < TOL then
OUTPUT (p); (The procedure was successful.)
STOP
Step 5: Set i = i + 1.
Step 6: Set p0 = p1; (Update p0, q0, p1, q1.)
q0 = q1;
p1 = p;
q1 = f(p)
Step 7: OUTPUT (The method failed after N0 iterations, N0 =, N0);
(The procedure was unsuccessful.)
STOP.
Method of False Position:
INPUT: initial approximations p0, p1; tolerance TOL; maximum number of iterations N0.
OUTPUT: approximate solution p or message of failure
Step 1: Set i = 2;
q0 = f(p0);
q1 = f(p1);
Step 2: While i <= N0 do steps 3 7
Step 3: Set p = p1 q1(p1 p0)/(q1 q0). (Compute pi).
Step 4: If |p p1| < TOL then
OUTPUT (p); (The procedure was successful.)
STOP
Step 5: Set i = i + 1.
q = f(p).
Step 6: If q * q1 < 0 then set p0 = p1;
q0 = q1;
Step 7: Set p1 = p;
q1 = q.
Step 8: OUTPUT (The method failed after N0 iterations, N0 =, N0);
(The procedure was unsuccessful.)
STOP.
|