import scipy.optimize as resol
import matplotlib.pyplot as plt

# Question 2.
def a(n):
    f=lambda x: n*x**3+n**2*x-2
    x=resol.fsolve(f,0.)
    return x[0]
    
# Question 4.
lx=list(range(1,10))
ly=[n**2*a(n) for n in lx]
plt.plot(lx,ly)
plt.show()
