In [1]:
import numpy as np
import sympy as sym
import matplotlib.pyplot as plt
from IPython.display import display,Math
In [2]:
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}'))
$\displaystyle \frac{d}{dx}x^2 = 2x^1$
$\displaystyle \frac{d}{dx}x^3 = 3x^2$
$\displaystyle \frac{d}{dx}(3x^3) = 9x^2$
$\displaystyle \frac{d}{dx}(ax^n) = nax^{n-1}$
In [3]:
x = sym.symbols('x')

fx = x**2
dfx = sym.diff(fx)
In [4]:
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))))
Leibniz notation
$\displaystyle \quad f(x) = x^{2}, \quad \frac{df}{dx} = 2 x$
Lagrange notation
$\displaystyle \quad f(x) = x^{2}, \quad f' = 2 x$
Newton notation
$\displaystyle \quad f(x) = x^{2}, \quad \dot{f} = 2 x$
In [5]:
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()
Plot object containing:
[0]: cartesian line: -x**3 + 3 for x over (-3.0, 3.0)
[1]: cartesian line: -3*x**2 for x over (-10.0, 10.0)