This notebook calculates an example function that we'll be using in our videos of numerical integration and differentiation!


In [ ]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(-10.0,10.0,1000)
y = 1.0 + 3.0*x + 2.0*x**2*np.sin(8.0*x)

In [ ]:
plt.plot([0,2],[0,0],'k-')
plt.plot(x,y,linewidth=3)
plt.xlim(0,2.0)
plt.ylim(0.0,15.0)
plt.xticks(np.linspace(0.0,2.0,11),fontsize=12)
plt.xlabel('x',fontsize=18)
plt.ylabel('f(x)',fontsize=18)
plt.text(0.2,12,r'$f(x) = 1 + 3\mathrm{x}+ 2\mathrm{x}^2\sin(\mathrm{8x})$',fontsize=14)
plt.savefig('example_function.png',dpi=300)