Tuesday, August 10, 2021

Thebe Python: SymPy Integration

✒️   SymPy Integration

!pip install -q sympy
import sympy as sp
sp.init_printing(use_unicode=True)
x,a,b=sp.symbols('x,a,b')
f21=x*(a*x**2+b)**(1/3)
intf21=sp.integrate(f21,x).simplify()
display([f21,intf21])
sp.pprint(75*'=')
p=sp.plot(f21.subs({a:1,b:2}),(x,-10,10),
          line_color='#3636ff',ylim=(-50,50),show=False)
ip=sp.plot(intf21.subs({a:1,b:2}),(x,-10,10),
           line_color='#36ff36',ylim=(-50,50),show=False)
p.extend(ip); p.show()

No comments:

Post a Comment