''' Compute real, positive, root of the 4th order polynomial: x^4 + 3x^3 -2x -6 = 0 by iteration(s). Try the following iterations, obtained by leaving only one term containing x on the left-hand side: x^4 = -3x^3 +2x +6 => next x <-- [-3x^3 +2x +6]^(1/4) 3x^3 = -x^4 +2x +6 => next x <-- [(-x^4 +2x +6)/3]^(1/3) 2x = x^4 +3x^3 -6 => next x <-- [(x^4 +3x^3 -6)/2]^(1/3) From someone who plotted this polynomial we know that there is a single positive root somewhere between x=1.2 and x=1.6. An unverified report says that the polynomial is actually (x^3-2)(x+3), so our real positive root should be x= 2^(1/3) ~ 1.26 Let's check! Our method will then be applicable to polynomials that don't have known factorization/solutions. ''' x = 1.4 # starting from this guess i = 0 # couter of iterations while (i < 45) : # do 45-1 iterations i = i + 1 # update counter # x = (-3*x**3 +2*x +6)**0.25 <-approached two *complex* roots x = ( (-x**4 +2*x +6) / 3) **(1/3) # converges to +-machine prec. print("in iteration",i," x = ",x) print("exact sol. x = 2^(1/3)=",2**(1/3) ) # now see if the 3rd iteration scheme works!