''' 1. Compute real, positive, root 4th order polynomial. x^4 + 3x^3 -2x -6 = 0 by iteration(s). Try the following iterations: x^4 (next) = -3x^3 +2x +6 3x^3 (next) = -x^4 +2x +6 2x (next) = x^4 +3x^3 -6 From someone who plotted this polynomial we know that there is a single positive root somewhere between x=1.2 and x=1.6. 2. An unverified report says the result should be x = 2**(1/3). Check it analytically and numerically. ''' def f(x): # right hand side of iteration eq. return ((-x**4 +2.*x +6.)/3.)**(1./3.) # main program x = 1.4 # staring from a guess print("\n start with x = ",x) for i in range(1,44): incr = f(x) - x x = f(x) print("iteration",i," x = ",x," increment",incr) if (x == 2.**(1/3) ): print("iteration converged to 2^(1/3) exactly, i.e. to machine precision! \n") else: print("iteration differs from 2^(1/3) by",x-2.**(1/3))