sympy
Use this skill when working with symbolic mathematics in Python. This skill should be used for symbolic computation tasks including solving equations algebraically, performing calculus operations (derivatives, integrals, limits), manipulating algebraic expressions, working with matrices symbolically, physics calculations, number theory problems, geometry computations, and generating executable code from mathematical expressions. Apply this skill when the user needs exact symbolic results rather than numerical approximations, or when working with mathematical formulas that contain variables and parameters.
Author
Category
AI Skill DevelopmentInstall
Download and extract to your skills directory
Copy command and send to OpenClaw for auto-install:
SymPy - Python Symbolic Mathematics Computation Intelligent Skill
Skill Overview
SymPy is a powerful Python library for symbolic mathematical computations, capable of performing exact symbolic operations including symbolic algebra, calculus, equation solving, matrix operations, and physics computations. Unlike numerical computation, SymPy uses mathematical symbols for exact calculations, keeping results like √2 in exact form rather than the approximate 1.414.
Use Cases
Core Features
Frequently Asked Questions
What's the difference between SymPy and NumPy?
SymPy is for symbolic computation, preserving exact mathematical forms (like √2), suitable for mathematical derivation and analytical solving; NumPy is for numerical computation, performing floating-point operations, suitable for large-scale numerical computing and data analysis. They are often used together: use SymPy for symbolic derivation and NumPy for numerical computation.
How do I solve equations with SymPy?
Use the solve() or solveset() functions. For example, to solve x² - 4 = 0:from sympy import symbols, solve; x = symbols('x'); solve(x**2 - 4, x) returns [-2, 2]. For differential equations, use the dsolve() function.
What mathematical operations does SymPy support?
SymPy supports complete symbolic mathematical operations, including: algebra (simplification, expansion, factorization), calculus (derivatives, integrals, limits), linear algebra (matrix operations, eigenvalues), number theory, geometry, physics computations, combinatorics, probability and statistics, as well as code generation and LaTeX output.
Can SymPy compute derivatives and integrals?
Yes. Use diff() for derivatives: diff(x**3, x) returns 3x². Use integrate() for integrals: integrate(x**2, x) returns x³/3. It supports multivariable partial derivatives, higher-order derivatives, definite integrals, and improper integrals.
How do I convert SymPy results to LaTeX?
Use the latex() function. For example:from sympy import latex, symbols; x = symbols('x'); expr = x**2 + 1; print(latex(expr)) outputs x^{2} + 1, which can be used directly in LaTeX documents or web displays of mathematical formulas.