Exercise 152

By using the matplotlib module, write a python algorithm which draw the curve of functions f(x) = x2 and g(x) = 2x +1 on the interval [-3 , +3] and solve the equation x2 -2x -1 graphically.

Solution


import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-3, 3, 100)
y = x**2
z = 2*x + 1
plt.plot(x,y)
plt.plot(x , z)
plt.show()


Younes Derfoufi
my-courses.net

Leave a Reply