Reputation: 15673
Consider this python script
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0,1,100)
def y(x,z):
return x**2 + z**-1 - 1
for z in np.arange(1,50,1):
plt.plot(x, y(x,z))
At a fixed x, how can I draw
plt.plot(z, y(x,z))
plt.plot(z, y(x,z).derivative) #dy/dz
Upvotes: 0
Views: 135
Reputation: 243897
You must use the derivative
function:
import numpy as np
import matplotlib.pyplot as plt
from scipy.misc import derivative
x = np.linspace(0,1,100)
def y(z, x):
return x**2 + z**(-1) - 1
z = np.arange(1.0, 50.0)
dydz = [derivative(y, zi, args=(x, )) for zi in z]
plt.plot(z, dydz)
plt.show()
Screenshot:
Upvotes: 1