import numpy as np
import sympy as sym
import matplotlib.pyplot as plt
from IPython.display import display,Math
display(Math('\\frac{d}{dx}x^2 = 2x^1'))
display(Math('\\frac{d}{dx}x^3 = 3x^2'))
display(Math('\\frac{d}{dx}(3x^3) = 9x^2'))
display(Math('\\frac{d}{dx}(ax^n) = nax^{n-1}'))
x = sym.symbols('x')
fx = x**2
dfx = sym.diff(fx)
print('Leibniz notation')
display(Math('\\quad f(x) = %s, \\quad \\frac{df}{dx} = %s' %(sym.latex(fx),sym.latex(dfx))))
print('Lagrange notation')
display(Math('\\quad f(x) = %s, \\quad f\' = %s' %(sym.latex(fx),sym.latex(dfx))))
print('Newton notation')
display(Math('\\quad f(x) = %s, \\quad \\dot{f} = %s' %(sym.latex(fx),sym.latex(dfx))))
import sympy.plotting.plot as symplot
fx = 3 - x**3
p = symplot(fx,(x,-3,3),show=False)
p.extend(symplot(sym.diff(fx),show=False))
print(p)
p[1].line_color = 'r'
p[0].label = '$f(x) = %s$' %sym.latex(fx)
p[1].label = '$f(x) = %s$' %sym.latex(sym.diff(fx))
p.legend = True
p.ylim = [-10,10]
p.xlim = [-3,3]
p.show()