sympy

Perform symbolic mathematics in Python including algebra, calculus, equation solving, and code generation.

Updated Aug 12, 2026
One-click install
npx skills add https://github.com/littlt-momo-c-yfc/skills --skill sympy-littlt-momo-c-yfc
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sympy
Source: https://github.com/littlt-momo-c-yfc/skills/tree/main/skills/scientific-toolkit-skill/references/scientific-skills/sympy
Command: npx skills add https://github.com/littlt-momo-c-yfc/skills --skill sympy-littlt-momo-c-yfc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires sympy, numpy, matplotlib, scipy, and includes references (resource) components.

What problem does it solve? Numerical approximations lose precision and cannot manipulate formulas with unknown variables. This Skill provides exact symbolic computation in Python using SymPy, so you can solve equations algebraically, compute exact derivatives and integrals, and manipulate mathematical expressions containing symbols and parameters. ## Core Features & Use Cases - Symbolic Algebra & Calculus: Simplify expressions, compute derivatives, integrals, limits, and series expansions with exact results like sqrt(2) instead of 1.414. - Equation Solving & Linear Algebra: Solve algebraic, differential, and systems of equations; work with matrices, eigenvalues, and decompositions symbolically. - Code Generation & Output: Convert symbolic expressions into fast NumPy functions via lambdify, generate C/Fortran code, and produce LaTeX output for documents. - Use Case: Derive a formula symbolically, verify it by substitution, then convert it with lambdify into a NumPy function to evaluate over thousands of data points for plotting with Matplotlib. ## Quick Start Use the sympy skill to solve the equation x^2 - 5x + 6 = 0 symbolically and then compute the definite integral of x*e^(-x^2) from 0 to infinity.

Frequently Asked Questions about sympy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I solve equations symbolically in Python?

Use SymPy's solveset for algebraic equations, linsolve for linear systems, nonlinsolve for nonlinear systems, and dsolve for differential equations. Define variables first with symbols(), then pass the equation and variable to the appropriate solver.

How to compute derivatives and integrals with SymPy?

Use diff(expr, x) for derivatives and integrate(expr, x) for indefinite integrals, or integrate(expr, (x, a, b)) for definite ones. SymPy returns exact symbolic results rather than numerical approximations.

What is the difference between SymPy and NumPy for math?

SymPy performs exact symbolic computation with variables and formulas, while NumPy performs fast numerical computation on arrays. Use lambdify to convert a SymPy expression into a NumPy function when you need both symbolic derivation and numerical speed.

Why does SymPy give wrong results with decimal numbers?

Floats like 0.5 introduce approximation errors in symbolic math. Use Rational(1, 2) or S(1)/2 for exact fractions, and call evalf() only when you need a final numerical value.

Why is SymPy slow when evaluating expressions in a loop?

Repeatedly calling subs() and evalf() is slow because each call runs symbolic machinery. Convert the expression once with lambdify(x, expr, 'numpy') to get a fast function that works directly on NumPy arrays.

Can SymPy generate LaTeX or C code from expressions?

Yes. The latex() function converts expressions to LaTeX strings for documents, and sympy.utilities.codegen produces C or Fortran source code. The autowrap function can even compile expressions into callable Python functions.