determine the highest real root of f(X)= 2x^3 – 11.7x^2 +17.7x -5 (with python)

question is about : determine the highest real root of f(X)= 2x^3 - 11.7x^2 +17.7x -5

with fixed – point iteration method (three iteration, x0 = 3)

i tried with python code :

import numpy as np
x= 1    
for i in range(3):
      x = 2*(x**3)-11.7*(x**2)+17.7*(x)-5
      print(i,x)

the answer when i run this code is not right. what is wrong with my code? thanks.

Answer

For the fixed-point iteration method you need to convert your original function f(x) into an expression of the form x = g(x). Then iterate using the latter.

This is easy for a polynomial. In your case:

x = -(2 * x**3 - 11.7 * x**2 - 5) / 17.7