math-to-python

Converts textbook equations and derivations into tested Python implementations for fluid dynamics.

Updated Sep 13, 2026
One-click install
npx skills add https://github.com/shammun/fluidpy --skill math-to-python-shammun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: math-to-python
Source: https://github.com/shammun/fluidpy/tree/main/.claude/skills/math-to-python
Command: npx skills add https://github.com/shammun/fluidpy --skill math-to-python-shammun

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Turning the mathematics of a fluid mechanics textbook (definitions, theorems, numbered equations) into correct, testable Python code is error-prone: OCR extraction corrupts symbols, numerical methods must be chosen per equation type, and pitfalls like cancellation, singularities, and stiffness silently produce wrong results. ## Core Features & Use Cases - Transcription discipline: Render the defining book page, transcribe equations into LaTeX, verify symbolically with sympy against the book's stated special cases before writing any numerical code. - Method selection guide: A decision table maps each mathematical form (closed-form, implicit equation, integral, ODE IVP/BVP, eigenvalue problem, PDE, series) to the right scipy/numpy approach with its known failure modes. - Numerical pitfall checklist: Concrete rules for grids, boundary conditions, non-dimensionalisation, units (pint), cancellation, singularities, stiffness, and reproducibility, plus an accumulating lessons-learned log. - Use Case: Implementing the Blasius boundary-layer equation from the textbook: transcribe it, verify the flat-plate special case symbolically, solve it as a BVP with shooting and solve_bvp cross-checks, then validate before later chapters reuse it. ## Quick Start Ask the assistant to implement equation 8.42 from chapter 8 as a tested Python function following the math-to-python workflow.

Frequently Asked Questions about math-to-python

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

FAQPage Schema
How do I turn a textbook equation into Python code?

Transcribe the equation from the rendered book page into LaTeX, verify it symbolically with sympy against the book's stated special cases, then implement it with the book's own symbol names and an equation-number comment. Validate the result before any later chapter reuses the function.

What numerical method should I use for a boundary-value ODE like Blasius?

Use shooting with brentq on the missing initial condition and scipy.integrate.solve_bvp, implementing one and cross-checking with the other. For infinite domains, truncate at a finite eta_max and show the answer is insensitive to that choice.

How do I solve implicit equations like Colebrook in Python?

Use scipy.optimize.brentq with a bracket derived from the physics of the problem, and always assert the residual after solving. Use newton only when an analytic derivative is available, since brackets can fail at extreme parameter values.

Why does my fluid dynamics simulation produce NaNs or wrong values?

Common causes are cancellation near special points, singularities at r=0 or stagnation points, stiffness requiring implicit solvers, and unstable time steps. Assert stability criteria like dt <= dx^2/(2*nu) and use rearranged forms such as np.expm1 and np.log1p.

Should I implement dimensional or non-dimensional equations?

Implement the non-dimensional equations, since that is what the textbook analyses, and provide a thin dimensional wrapper built from reference scales. Keep the scales in one dataclass per chapter so a change of reference length cannot silently leak.