Skip to main content
sympy Python library for symbolic mathematics — exact algebra, calculus, equation solving, matrices, and LaTeX/code generation instead of numeric approximation. USE WHEN a research task needs exact symbolic results: solving equations, derivatives/integrals, simplification, or deriving closed-form expressions.
Aller à l'installation Skills Marketplace Découvrez et explorez les compétences IA créées par la communauté.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Copier le promptAfficher les détails du prompt Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
npx skills add https://github.com/Sheshiyer/skill-clusters --skill sympyLa commande reste sur une seule ligne. Faites défiler horizontalement pour la vérifier avant de la copier.
Vous préférez une copie locale ? Téléchargez les fichiers actuellement disponibles dans SkillsMP.
Télécharger Zip Téléchargement... Plus depuis ce dépôt Arcplume runs Grok through the Grok Build CLI's own OAuth-authenticated session (grok login) for image generation, with strict preflight validation, secret-safe handling, and headless CLI-driven execution -- no separate XAI_API_KEY billing. Video falls back to the billed xAI API. USE WHEN a user wants to generate an image via a locally logged-in Grok Build CLI session, e.g. 'generate an image with grok', 'use grok build', or 'use my logged-in grok session'.
Shared reference for the Selemene cluster: the two report surfaces (deterministic Rust reports vs. narrative witness-pipeline readings), the @selemene/bridge CLI contract, the output manifest format, and non-prescriptive witnessing tone. USE WHEN deciding which Selemene surface to invoke or when routing between birth/compatibility/transit reports and solo/dyadic readings.
Route Selemene Engine tasks to the right surface: deterministic reports (birth/compatibility/transit) via selemene-core and the @selemene/bridge CLI, or narrative witness readings via selemene-report. USE WHEN the user wants anything under the Selemene/Noesis umbrella but has not named the exact surface.
Métiers associés SOC
Basé sur la classification professionnelle SOC
name sympy description Python library for symbolic mathematics — exact algebra, calculus, equation solving, matrices, and LaTeX/code generation instead of numeric approximation. USE WHEN a research task needs exact symbolic results: solving equations, derivatives/integrals, simplification, or deriving closed-form expressions. cluster research-knowledge version 1.0.0 origin antigravity-awesome-skills (MIT) license https://github.com/sympy/sympy/blob/master/LICENSE metadata {"skill-author":"K-Dense Inc."} risk unknown source https://github.com/sympy/sympy
SymPy - Symbolic Mathematics in Python
Overview
SymPy is a Python library for symbolic mathematics that enables exact computation using mathematical symbols rather than numerical approximations. This skill provides comprehensive guidance for performing symbolic algebra, calculus, linear algebra, equation solving, physics calculations, and code generation using SymPy.
When to Use This Skill
Use this skill when:
Solving equations symbolically (algebraic, differential, systems of equations)
Performing calculus operations (derivatives, integrals, limits, series)
Manipulating and simplifying algebraic expressions
Working with matrices and linear algebra symbolically
Doing physics calculations (mechanics, quantum mechanics, vector analysis)
Number theory computations (primes, factorization, modular arithmetic)
Geometric calculations (2D/3D geometry, analytic geometry)
Converting mathematical expressions to executable code (Python, C, Fortran)
Generating LaTeX or other formatted mathematical output
Needing exact mathematical results (e.g., sqrt(2) not 1.414...)
Core Capabilities
1. Symbolic Computation Basics
Creating symbols and expressions:
from sympy import symbols, Symbol
x, y, z = symbols('x y z' )
expr = x**2 + 2 *x + 1
x = symbols('x' , real=True , positive=True )
n = symbols('n' , integer=True )
Simplification and manipulation:
from sympy import simplify, expand, factor, cancel
simplify(sin(x)**2 + cos(x)**2 )
expand((x + 1 )**3 )
factor(x**2 - 1 )
For detailed basics: See references/core-capabilities.md
2. Calculus from sympy import diff
diff(x**2 , x)
diff(x**4 , x, 3 )
diff(x**2 *y**3 , x, y)
from sympy import integrate, oo
integrate(x**2 , x)
integrate(x**2 , (x, 0 , 1 ))
integrate(exp(-x), (x, 0 , oo))
from sympy import limit, series
limit(sin(x)/x, x, 0 )
series(exp(x), x, 0 , 6 )
For detailed calculus operations: See references/core-capabilities.md
3. Equation Solving from sympy import solveset, solve, Eq
solveset(x**2 - 4 , x)
solve(Eq(x**2 , 4 ), x)
from sympy import linsolve, nonlinsolve
linsolve([x + y - 2 , x - y], x, y)
nonlinsolve([x**2 + y - 2 , x + y**2 - 3 ], x, y)
from sympy import Function, dsolve, Derivative
f = symbols('f' , cls=Function)
dsolve(Derivative(f(x), x) - f(x), f(x))
For detailed solving methods: See references/core-capabilities.md
4. Matrices and Linear Algebra Matrix creation and operations:
from sympy import Matrix, eye, zeros
M = Matrix([[1 , 2 ], [3 , 4 ]])
M_inv = M**-1
M.det()
M.T
Eigenvalues and eigenvectors:
eigenvals = M.eigenvals()
eigenvects = M.eigenvects()
P, D = M.diagonalize()
A = Matrix([[1 , 2 ], [3 , 4 ]])
b = Matrix([5 , 6 ])
x = A.solve(b)
For comprehensive linear algebra: See references/matrices-linear-algebra.md
5. Physics and Mechanics from sympy.physics.mechanics import dynamicsymbols, LagrangesMethod
from sympy import symbols
q = dynamicsymbols('q' )
m, g, l = symbols('m g l' )
L = m*(l*q.diff())**2 /2 - m*g*l*(1 - cos(q))
LM = LagrangesMethod(L, [q])
from sympy.physics.vector import ReferenceFrame, dot, cross
N = ReferenceFrame('N' )
v1 = 3 *N.x + 4 *N.y
v2 = 1 *N.x + 2 *N.z
dot(v1, v2)
cross(v1, v2)
from sympy.physics.quantum import Ket, Bra, Commutator
psi = Ket('psi' )
A = Operator('A' )
comm = Commutator(A, B).doit()
For detailed physics capabilities: See references/physics-mechanics.md
6. Advanced Mathematics The skill includes comprehensive support for:
Geometry: 2D/3D analytic geometry, points, lines, circles, polygons, transformations
Number Theory: Primes, factorization, GCD/LCM, modular arithmetic, Diophantine equations
Combinatorics: Permutations, combinations, partitions, group theory
Logic and Sets: Boolean logic, set theory, finite and infinite sets
Statistics: Probability distributions, random variables, expectation, variance
Special Functions: Gamma, Bessel, orthogonal polynomials, hypergeometric functions
Polynomials: Polynomial algebra, roots, factorization, Groebner bases
For detailed advanced topics: See references/advanced-topics.md
7. Code Generation and Output Convert to executable functions:
from sympy import lambdify
import numpy as np
expr = x**2 + 2 *x + 1
f = lambdify(x, expr, 'numpy' )
x_vals = np.linspace(0 , 10 , 100 )
y_vals = f(x_vals)
from sympy.utilities.codegen import codegen
[(c_name, c_code), (h_name, h_header)] = codegen(
('my_func' , expr), 'C'
)
from sympy import latex
latex_str = latex(expr)
For comprehensive code generation: See references/code-generation-printing.md
Working with SymPy: Best Practices
1. Always Define Symbols First from sympy import symbols
x, y, z = symbols('x y z' )
2. Use Assumptions for Better Simplification x = symbols('x' , positive=True , real=True )
sqrt(x**2 )
Common assumptions: real, positive, negative, integer, rational, complex, even, odd
3. Use Exact Arithmetic from sympy import Rational, S
expr = Rational(1 , 2 ) * x
expr = S(1 )/2 * x
expr = 0.5 * x
4. Numerical Evaluation When Needed from sympy import pi, sqrt
result = sqrt(8 ) + pi
result.evalf()
result.evalf(50 )
5. Convert to NumPy for Performance
for x_val in range (1000 ):
result = expr.subs(x, x_val).evalf()
f = lambdify(x, expr, 'numpy' )
results = f(np.arange(1000 ))
6. Use Appropriate Solvers
solveset: Algebraic equations (primary)
linsolve: Linear systems
nonlinsolve: Nonlinear systems
dsolve: Differential equations
solve: General purpose (legacy, but flexible)
Reference Files Structure This skill uses modular reference files for different capabilities:
core-capabilities.md : Symbols, algebra, calculus, simplification, equation solving
Load when: Basic symbolic computation, calculus, or solving equations
matrices-linear-algebra.md : Matrix operations, eigenvalues, linear systems
Load when: Working with matrices or linear algebra problems
physics-mechanics.md : Classical mechanics, quantum mechanics, vectors, units
Load when: Physics calculations or mechanics problems
advanced-topics.md : Geometry, number theory, combinatorics, logic, statistics
Load when: Advanced mathematical topics beyond basic algebra and calculus
code-generation-printing.md : Lambdify, codegen, LaTeX output, printing
Load when: Converting expressions to code or generating formatted output
Common Use Case Patterns
Pattern 1: Solve and Verify from sympy import symbols, solve, simplify
x = symbols('x' )
equation = x**2 - 5 *x + 6
solutions = solve(equation, x)
for sol in solutions:
result = simplify(equation.subs(x, sol))
assert result == 0
Pattern 2: Symbolic to Numeric Pipeline
x, y = symbols('x y' )
expr = sin(x) + cos(y)
simplified = simplify(expr)
derivative = diff(simplified, x)
f = lambdify((x, y), derivative, 'numpy' )
results = f(x_data, y_data)
Pattern 3: Document Mathematical Results
integral_expr = Integral(x**2 , (x, 0 , 1 ))
result = integral_expr.doit()
print (f"LaTeX: {latex(integral_expr)} = {latex(result)} " )
print (f"Pretty: {pretty(integral_expr)} = {pretty(result)} " )
print (f"Numerical: {result.evalf()} " )
Integration with Scientific Workflows
With NumPy import numpy as np
from sympy import symbols, lambdify
x = symbols('x' )
expr = x**2 + 2 *x + 1
f = lambdify(x, expr, 'numpy' )
x_array = np.linspace(-5 , 5 , 100 )
y_array = f(x_array)
With Matplotlib import matplotlib.pyplot as plt
import numpy as np
from sympy import symbols, lambdify, sin
x = symbols('x' )
expr = sin(x) / x
f = lambdify(x, expr, 'numpy' )
x_vals = np.linspace(-10 , 10 , 1000 )
y_vals = f(x_vals)
plt.plot(x_vals, y_vals)
plt.show()
With SciPy from scipy.optimize import fsolve
from sympy import symbols, lambdify
x = symbols('x' )
equation = x**3 - 2 *x - 5
f = lambdify(x, equation, 'numpy' )
solution = fsolve(f, 2 )
Quick Reference: Most Common Functions
from sympy import symbols, Symbol
x, y = symbols('x y' )
from sympy import simplify, expand, factor, collect, cancel
from sympy import sqrt, exp, log, sin, cos, tan, pi, E, I, oo
from sympy import diff, integrate, limit, series, Derivative, Integral
from sympy import solve, solveset, linsolve, nonlinsolve, dsolve
from sympy import Matrix, eye, zeros, ones, diag
from sympy import And, Or, Not, Implies, FiniteSet, Interval, Union
from sympy import latex, pprint, lambdify, init_printing
from sympy import evalf, N, nsimplify
Getting Started Examples
Example 1: Solve Quadratic Equation from sympy import symbols, solve, sqrt
x = symbols('x' )
solution = solve(x**2 - 5 *x + 6 , x)
Example 2: Calculate Derivative from sympy import symbols, diff, sin
x = symbols('x' )
f = sin(x**2 )
df_dx = diff(f, x)
Example 3: Evaluate Integral from sympy import symbols, integrate, exp
x = symbols('x' )
integral = integrate(x * exp(-x**2 ), (x, 0 , oo))
Example 4: Matrix Eigenvalues from sympy import Matrix
M = Matrix([[1 , 2 ], [2 , 1 ]])
eigenvals = M.eigenvals()
Example 5: Generate Python Function from sympy import symbols, lambdify
import numpy as np
x = symbols('x' )
expr = x**2 + 2 *x + 1
f = lambdify(x, expr, 'numpy' )
f(np.array([1 , 2 , 3 ]))
Troubleshooting Common Issues
"NameError: name 'x' is not defined"
Solution: Always define symbols using symbols() before use
Unexpected numerical results
Issue: Using floating-point numbers like 0.5 instead of Rational(1, 2)
Solution: Use Rational() or S() for exact arithmetic
Slow performance in loops
Issue: Using subs() and evalf() repeatedly
Solution: Use lambdify() to create a fast numerical function
"Can't solve this equation"
Try different solvers: solve, solveset, nsolve (numerical)
Check if the equation is solvable algebraically
Use numerical methods if no closed-form solution exists
Simplification not working as expected
Try different simplification functions: simplify, factor, expand, trigsimp
Add assumptions to symbols (e.g., positive=True)
Use simplify(expr, force=True) for aggressive simplification
Additional Resources
Limitations
Use this skill only when the task clearly matches the scope described above.
Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.