import sympy as sp

x = sp.symbols('x')

def newton(f,x0,eps=0.0001):
    f_prime = sp.diff(f, x)
    xn= x0+1
    while abs(xn-x0) > eps:
        x0, xn = xn, xn - f.subs(x,xn)/f_prime.subs(x,xn)

    return xn

# Définir la fonction
f = 0.25*x**2 + 0.4*x - 3

# On affiche la solution
print(newton(f,0))
