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.

Install

Hot:7

Download and extract to your skills directory

Copy command and send to OpenClaw for auto-install:

Download and install this skill https://openskills.cc/api/download?slug=k-dense-ai-scientific-skills-sympy&locale=en&source=copy

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

  • Symbolic Equation Solving - When you need exact solutions for algebraic equations, differential equations, or systems of equations, SymPy can provide analytical solutions rather than numerical approximations, suitable for mathematical derivation, research computing, and engineering analysis.
  • Calculus and Mathematical Analysis - Perform symbolic differentiation, integration, limit computation, and series expansion, suitable for math teaching, theoretical derivation, and research scenarios requiring exact mathematical expressions.
  • Mathematical Expression Manipulation and Code Generation - Simplify complex mathematical expressions, generate LaTeX output, or convert mathematical formulas into executable Python/C/Fortran code.
  • Core Features

  • Basic Symbolic Computation - Supports creating symbolic variables, expression simplification, expansion, factorization, as well as symbolic operations for trigonometric functions, exponentials, logarithms, etc., enabling exact algebraic transformations of mathematical expressions.
  • Calculus Operations - Provides full symbolic calculus capabilities, including single-variable and multivariable differentiation, definite and indefinite integration, limit computation, Taylor series expansion, and symbolic solving of differential equations.
  • Equation and Matrix Solving - Supports symbolic solving of algebraic equations, systems of equations, and differential equations, as well as symbolic matrix operations, eigenvalue decomposition, solving linear systems, and other linear algebra 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.