Deriv

Plotting a trig function and its derivative with Python

#!/usr/bin/env python3
import numpy as n,matplotlib.pyplot as p
x=n.linspace(-4,4,400)
f=n.arctan(x**2);df=2*x/(x**4+1)
p.plot(x,f,'b',label='f(x)=arctan(x²)')
p.plot(x,df,'r',label="f'(x)=2x/(x⁴+1)")
p.axhline(0,c='k',lw=.5);p.axvline(0,c='k',lw=.5)
p.ylim(-2,2);p.xlabel('x');p.ylabel('y')
p.title("f(x) and f'(x)")
p.grid(ls=':',alpha=.7);p.legend();p.show()

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment