sympy
ScienceSymbolic math
What is sympy?
SymPy is a Python library for symbolic mathematics. Unlike NumPy and SciPy which work with numerical approximations, SymPy manipulates mathematical expressions algebraically — it can expand polynomials, factor expressions, compute exact derivatives and integrals, solve equations, and work with matrices symbolically.
Running SymPy in PyRun is especially useful for students studying calculus, algebra, or differential equations. You can verify manual calculations, explore symbolic patterns, and get exact answers rather than floating-point approximations — all without installing anything on your machine.
Code Example
Symbolic expansion, differentiation, integration.
SymPy Algebra & Calculus
Try in Editorimport sympy as sp
x, y = sp.symbols('x y')
# Expand and factor
expr = (x + y)**3
print("Expanded (x+y)³:", sp.expand(expr))
print("Factored back:", sp.factor(sp.expand(expr)))
# Calculus
f = sp.sin(x) * sp.exp(x)
print("\nf(x) =", f)
print("f'(x) =", sp.diff(f, x))
print("∫f dx =", sp.integrate(f, x))
# Solve equation
eq = sp.Eq(x**2 - 5*x + 6, 0)
print("\nSolve x²-5x+6=0:", sp.solve(eq, x))Why run sympy in PyRun?
- ✦ Zero setup — no pip install, no virtual environment, no Python download
- ✦ Instant results — powered by WebAssembly, runs locally in your browser
- ✦ Share your code — generate a link and anyone can run it instantly
- ✦ Works offline — after first load, PyRun runs without internet