Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- from scipy.misc import derivative as D
- f = lambda x: x**2 # <--- INSERT FUNCTION AFTER THE COLON HERE
- der = lambda x: D(f, x)
- def main():
- r = range(-30, 30) # This is the X-Range that the graph will be shown on
- x = [i for i in r]
- f1 = [f(i) for i in r]
- f2 = [der(i) for i in r]
- plt.plot(x, f1, label='Original')
- plt.plot(x, f2, label='Derivative')
- plt.grid()
- plt.legend()
- plt.show()
- main()
Add Comment
Please, Sign In to add comment