sympy-numpy-scipy-boundaries

Compile symbolic SymPy expressions into verified NumPy and SciPy numerical workflows.

Updated Aug 12, 2026
One-click install
npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill sympy-numpy-scipy-boundaries-schattenspiegel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sympy-numpy-scipy-boundaries
Source: https://github.com/schattenspiegel/skill-foundry-skills/tree/main/skills/sympy-numpy-scipy-boundaries
Command: npx skills add https://github.com/schattenspiegel/skill-foundry-skills --skill sympy-numpy-scipy-boundaries-schattenspiegel

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Crossing from symbolic mathematics into numerical computing introduces silent errors: wrong symbol ordering, dtype mismatches, domain violations, and solver results accepted on a success flag alone. This Skill enforces explicit contracts at the SymPy-to-NumPy-to-SciPy boundary so numerical results stay faithful to the original mathematics. ## Core Features & Use Cases - Explicit lambdify contracts: Define symbol order, modules selection, input shapes, broadcasting, dtypes, and singular-point behavior before vector evaluation. - SciPy solver adaptation: Adapt lambdified callables to root-finding, least-squares, minimization, and integration signatures, then validate with residuals, constraints, and multiple starts or brackets. - Cross-boundary verification: Cross-check numerical results against higher-precision SymPy/mpmath or independent formulations, including finite-difference checks of symbolic Jacobians. - Use Case: You derived a symbolic expression like exp(-a*x) - x and need its root for a given parameter. The Skill guides you to lambdify with an explicit ordered tuple, solve with a bracketed brentq call, and reject the result unless the residual falls below tolerance. ## Quick Start Use the sympy-numpy-scipy-boundaries skill to lambdify my symbolic expression and solve it with SciPy, verifying the residual and domain assumptions.

Frequently Asked Questions about sympy-numpy-scipy-boundaries

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

FAQPage Schema
How do I convert a SymPy expression to a NumPy function?▼

Use sympy.lambdify with symbols supplied as an ordered tuple and modules="numpy" for vector evaluation. Test the returned callable on both scalar and array inputs, since translation can change dtypes, branch behavior, and handling of singular points.

How do I use a SymPy expression with SciPy optimize solvers?▼

Lambdify the expression first, then wrap it to match the solver's signature, such as a scalar residual for brentq or a vector residual for least squares. Never rely on implicit symbol order, and validate the result with residuals and constraints rather than the success flag alone.

When should I use a bracketed solver versus a local solver in SciPy?▼

Use a bracketed solver like brentq when a sign-changing interval is available, since it guarantees convergence within the bracket. Use a local solver only when you have a defensible initial estimate and basin assumptions, and consider multiple starts for initialization-sensitive problems.

Why does lambdify produce warnings or wrong values for piecewise expressions?▼

Generated NumPy code may evaluate masked branches of Piecewise expressions, emitting warnings or producing unexpected dtypes. Test every branch and boundary explicitly, and inspect behavior at domain edges instead of assuming algebraic equivalence implies floating-point equivalence.

Is it safe to lambdify untrusted symbolic expressions?▼

No. lambdify uses code generation and is not a sandbox, so untrusted input should not be passed to sympify or lambdify as a security boundary. Parse untrusted input against an explicit safe grammar outside this workflow.