In [1]:
import sympy as sym
from IPython.display import display,Math
In [2]:
print('Integral')
display(Math('\\quad \int_{a}^{b} f(x) \\: dx'))
print('Indefinite integral')
display(Math('\\quad \int bx^a \\: dx = \\frac{bx^{a+1}}{a+1}+c'))
display(Math('\\quad \int 4x^2 \\: dx = \\frac{4x^3}{3}+c'))
Integral
$\displaystyle \quad \int_{a}^{b} f(x) \: dx$
Indefinite integral
$\displaystyle \quad \int bx^a \: dx = \frac{bx^{a+1}}{a+1}+c$
$\displaystyle \quad \int 4x^2 \: dx = \frac{4x^3}{3}+c$
In [3]:
x = sym.symbols('x')

f = x

print(sym.integrate(f))
p = sym.plotting.plot(f,show=False)
p.xlim = [0,1]
p.ylim = [0,1]
p.show()
x**2/2
<Figure size 640x480 with 1 Axes>
In [4]:
sym.integrate(f,(x,0,1))
Out[4]:
1/2
In [5]:
f = x**3 / (x-2)
intf = sym.integrate(f)
print(intf)

p = sym.plotting.plot(f,show=False)
p.extend(sym.plotting.plot(intf,(x,2.1,10),show=False,line_color='r'))

p[0].label = '$f(x) = %s$' %(sym.latex(f))
p[1].label = '$\\int f(x) dx = %s$' %(sym.latex(intf))

p.ylim = [-200,200]
p.legend = True
p.show()
x**3/3 + x**2 + 4*x + 8*log(x - 2)