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.
import 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
Related Packages
Recommended Python Resources
Expand your knowledge with related interactive tutorials, cheat sheets, and code comparisons.
Python Loops
Learn how to use Python loops to iterate over data. Master for loops, while loops, break, continue, and loop best practices with interactive examples.
How to Sort a List in Python
Learn how to sort a list in Python using the sort() method and the sorted() function. Discover custom key sorting and reverse order examples.
Python String Methods
A complete reference guide for Python string manipulation. Master formatting, searching, splitting, replacing, and checking string properties.
Python vs JavaScript: Which Programming Language is Best?
A comprehensive comparison between Python and JavaScript. Explore syntax differences, performance, use cases (backend vs frontend), and coding examples.