sympy

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

1|Updated Aug 24, 2026
One-click install
npx skills add https://github.com/CliffVale/opencode-free-setup --skill sympy-cliffvale
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sympy
Source: https://github.com/CliffVale/opencode-free-setup/tree/main/skills/sympy
Command: npx skills add https://github.com/CliffVale/opencode-free-setup --skill sympy-cliffvale

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Numerical libraries like NumPy return floating-point approximations, which lose precision and cannot manipulate mathematical expressions symbolically. This Skill provides exact symbolic computation in Python so you can solve equations, compute derivatives and integrals, and simplify expressions with mathematically exact results like sqrt(2) instead of 1.414. ## Core Features & Use Cases - Symbolic Algebra and Calculus: Simplify, expand, and factor expressions; compute derivatives, integrals, limits, and series expansions exactly. - Equation Solving and Linear Algebra: Solve algebraic, differential, linear, and nonlinear systems; work with matrices, eigenvalues, and decompositions symbolically. - Code Generation and Output: Convert symbolic expressions to fast NumPy functions via lambdify, generate C/Fortran code, and produce LaTeX output for documentation. - Use Case: Derive a formula symbolically, verify it by substitution, then lambdify it into a NumPy function to evaluate over thousands of data points, and export the result as LaTeX for a report. ## Quick Start Use the sympy skill to solve the equation x^2 - 5x + 6 = 0 symbolically and then compute the exact 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 symbols first with symbols(), then pass the equation and variable, for example solveset(x**2 - 4, x) returns {-2, 2}.

When should I use SymPy instead of NumPy?▼

Use SymPy when you need exact symbolic results like sqrt(2), symbolic derivatives, integrals, or equation solving. Use NumPy when floating-point approximations are sufficient and you need fast numerical computation over large arrays.

How do I convert a SymPy expression to a fast numerical function?▼

Use lambdify to convert a symbolic expression into a NumPy-compatible function, for example f = lambdify(x, expr, 'numpy'). This is far faster than calling subs() and evalf() repeatedly in a loop.

Why does SymPy give approximate results for fractions?▼

Writing 0.5 * x creates a floating-point value instead of an exact rational. Use Rational(1, 2) or S(1)/2 to keep arithmetic exact, and call evalf() only when you need a numerical approximation.

Can SymPy generate LaTeX or C code from expressions?▼

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

Why is SymPy simplification not working as expected?▼

Simplification often depends on symbol assumptions. Define symbols with constraints like positive=True or real=True so functions like sqrt(x**2) simplify correctly, and try specific functions like trigsimp, factor, or expand instead of the general simplify.