False Position Algorithm
False Position Algorithm
1. Start
2. Read values of x0, x1 and e
*Here x0 and x1 are the two initial guesses
e is the degree of accuracy or the absolute error i.e. the stopping
criteria*
3. Computer function values f(x0) and f(x1)
4. Check whether the product of f(x0) and f(x1) is negative or not.
If it is positive take another initial guesses.
If it is negative then goto step 5.
5. Determine:
x = [x0*f(x1) – x1*f(x0)] / (f(x1) – f(x0))
6. Check whether the product of f(x1) and f(x) is negative or not.
If it is negative, then assign x0 = x;
If it is positive, assign x1 = x;
7. Check whether the value of f(x) is greater than 0.00001 or not.
If yes, goto step 5.
If no, goto step 8.
*Here the value 0.00001 is the desired degree of accuracy, and
hence the stopping criteria.*
8. Display the root as x.
9. Stop
Example:
Set .
set
Regula Falsi
Method
Iteration
no.
0 1.0000000000 2.0000000000 1.4782608747 -2.2348976135
1 1.4782608747 2.0000000000 1.6198574305 -0.5488323569
2 1.6198574305 2.0000000000 1.6517157555 -0.1169833690
3 1.6517157555 2.0000000000 1.6583764553 -0.0241659321
4 1.6583764553 2.0000000000 1.6597468853 -0.0049594725
5 1.6597468853 2.0000000000 1.6600278616 -0.0010169938
6 1.6600278616 2.0000000000 1.6600854397 -0.0002089010
7 1.6600854397 2.0000000000 1.6600972414 -0.0000432589
8 1.6600972414 2.0000000000 1.6600997448 -0.0000081223
Example:
Regula Falsi
Method
Iteration
no.
0 0.5000000000 1.5000000000 0.8773435354 2.1035263538
1 0.5000000000 0.8773435354 0.7222673893 0.2828366458
2 0.5000000000 0.7222673893 0.7032044530 0.0251714624
3 0.5000000000 0.7032044530 0.7015219927 0.0021148270
4 0.5000000000 0.7015219927 0.7013807297 0.0001767781
5 0.5000000000 0.7013807297 0.7013689280 0.0000148928
6 0.5000000000 0.7013689280 0.7013679147 0.0000009526
1. Start
2. Read x, e, n, d
*x is the initial guess
e is the absolute error i.e the desired degree of accuracy
n is for operating loop
d is for checking slope*
3. Do for i =1 to n in step of 2
4. f = f(x)
5. f1 = f'(x)
6. If ( [f1] < d), then display too small slope and goto 11.
*[ ] is used as modulus sign*
7. x1 = x – f/f1
8. If ( [(x1 – x)/x1] < e ), the display the root as x1 and goto 11.
*[ ] is used as modulus sign*
9. x = x1 and end loop
10. Display method does not converge due to oscillation.
11. Stop
Example:
Solution:
Given
Take and
Since,
Iteration no.
Example:
Solution: Given
Say,
Iteration no.
False Position
syms x;
c=(a-(f(a)*(b-a))/(f(b)-f(a)));
itr=1;
while (abs(f(c))>e)
if(f(a)*f1(c)<0)
b=c;
else
a=c;
end
c=(a-(f(a)*(b-a))/(f(b)-f(a)));
itr=itr+1;
end
c
itr_no=itr
Newton Raphson
syms x;
end
x
u