top of page

Root Finding Techniques | Fixed Point Iteration Method

Manisha Sahu
In this article, we will be going to study the fixed point iteration method in numerical analysis and design using Python.
 

Algorithm


  • start

  • Read x,,epsilon(absolute error),x_before=0,i

  • Calculate f(x) and g(x) //f(x)=putting x in the fxn,g(x)=differentiation of f(x)

  • while (|x-x_before|>epsilon)

  • x_before=x

  • x=g(x)

  • print (i, "{0:.6f}".format(x), "{0:.6f}".format(abs(x - x_before)))

  • i=i+1

  • end loop

 

Flowchart



 

Program



def f(x):
    return (x**3 - 9*x + 1 )


def g(x):
    return (9*x-1)**(1/3)

epsilon = 0.0001


x = 2.7

x_before = 0

i = 0

while (abs(x - x_before) > epsilon):
    x_before = x
    x = g(x)

    print(i, "{0:.6f}".format(x), "{0:.6f}".format(abs(x - x_before)))
    i = i + 1
 

Example


Q]Q] Find the real root of equation x^3-9x+1=0 by fixed-point iteration method?


Solution-


f(0)=1 , f(1)=-7 , f(2)=-9 , f(3)=1
Since root of f(x)=0 lies between 2 and 3 so taking x0=2.7
 
Assumption-
x= (9x-1)^1/3
F(x)= (9x-1)^1/3
F’(x)=3/(9x-1)^2/3
Since F’(2.7) coming less than 1,satisfy the condition . So taking
x(n+1)=(9x(n)-1)^1/3
n=0 
x1=(9x0-1)^1/3=2.8562
x2=(9x1-1)^1/3=2.9125 -------------------------------------------
----------------------------------------
x7=2.9427
X8=2.9428
We get two approximate values having same decimal digits up to three places ,so the answer is 2.942
 
 

Happy Coding!

Follow us on Instagram @programmersdoor

Join us on Telegram @programmersdoor


Please write comments if you find any bug in the above code, or want some updates.

Follow Programmers Door for more.







 
 
 

Comments


bottom of page