Thread: Matlab
View Single Post
Old 07-24-2003, 05:53 PM   #11 (permalink)
slant eyes
Psycho
 
Location: cali
sorry it took so long, i had a quiz and for those interested in how well i did, i did awesome on it. well, here are the algorithms:

Bisection Method:

INPUT: endpoints a, b; tolerance TOL; maximum number of iterations N0 .

OUTPUT: approximate solution p or message of failure.

Step 1:

Set i = 1;
FA = f(a).

Step 2:
While i <= N0 do Steps 3 - 6

Step 3:
set p = a + (b-a)/2; (Compute pi .)
FP = f(p).

Step 4:
If FP = 0 or (b-a)/2 < TOL then
OUTPUT (p); (Procedure completed successfully.)
STOP.

Step 5:
Set i = i + 1.

Step 6:
If FA * FP > 0 then set a = p; (Compute ai , bi .)
FA = FP
else set b = p.

Step 7:
OUTPUT ('Method failed after N0 iterations, N0 =', N0);
(The procedure was unsuccessful.)

STOP.

Newton's Method:

INPUT: initial approximation p0; tolerance TOL; maximum number of iterations N0 .

OUTPUT: approximate solution p or message of failure.

Step 1:
Set i = 1;

Step 2:
While i <= N0 do Steps 3 - 6

Step 3:
Set p = p0 - f(p0) / f'(p0). (Compute pi.)

Step 4:
If | p - p0| < TOL then
OUTPUT (p); (The procedure was successful.)
STOP.

Step 5:
Set i = i + 1.

Step 6:
Set p0 = p; (Update p0.)

Step 7:
OUTPUT ('Method failed after N0 iterations, N0 =', N0);
(The procedure was unsuccessful.)

** i will add the other two, this one is getting too long, plus it'll give me a way to up my post count **
slant eyes is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73