
from scipy.optimize import fsolve #Find the roots of a function.
#Return the roots of the (non-linear) equations defined by func(x) = 0 given a starting estimate.
import matplotlib.pyplot as plt
import numpy as np

def f(x):
    f=x**2-x-1
    return f

x=fsolve(f,2)
print(x)

if __name__ == "__main__":
    if True: 
        xs = np.linspace( 0, 5, 50 ) 
        fs = [ f(_) for _ in xs ]

    

plt.plot( xs, fs )
plt.xlabel('x')
plt.ylabel('f(x)')
plt.axhline(y=0,color='k')
plt.grid(); 
plt.show()








