import numpy as np
def f(x): 
    return(4*x-np.exp(x))
def f_prime(x):
    return(4-np.exp(x))
def phi(x): 
    return(x-(f(x)/f_prime(x)))
n = 2
x = 0
eps = 10**-3
while abs(x-phi(x)) >= eps: 
    x = phi(x)
    n = n+1
print(x,n)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: