Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Apply numerical methods and scientific computing techniques
.claude/skills/brycewang-stanford-numerical-methods-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-03 | ✗→✓ | ▲ Improved | 69% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 63% | 0% |
| case-15 | ✗→✓ | ▲ Improved | 169% | 0% |
| case-22 | ✗→✓ | ▲ Improved | 1% | 0% |
| case-12 | ✓→✓ | = Same ✓ | 57% | 0% |
A skill for applying numerical methods in scientific computing and research. Covers root finding, numerical integration, ODE solvers, optimization, interpolation, and error analysis with practical implementations in Python.
pythonimport numpy as np def newton_method(f, df, x0: float, tol: float = 1e-10, max_iter: int = 100) -> dict: """ Newton's method for finding roots of f(x) = 0. Args: f: Function whose root we seek df: Derivative of f x0: Initial guess tol: Convergence tolerance max_iter: Maximum iterations """ x = x0 history = [x] for i in range(max_iter): fx = f(x) dfx = df(x) if abs(dfx) < 1e-15: return {"root": x, "converged": False, "reason": "Zero derivative encountered"} x_new = x - fx / dfx history.append(x_new) if abs(x_new - x) < tol: return { "root": x_new, "converged": True, "iterations": i + 1, "f_at_root": f(x_new), "convergence": "quadratic" } x = x_new return {"root": x, "converged": False, "reason": "Max iterations reached"}
| Method | Convergence | Requires | Robustness | |--------|------------|----------|-----------| | Bisection | Linear (slow) | Bracketing interval | Very robust | | Newton | Quadratic (fast) | Derivative | May diverge | | Secant | Superlinear (~1.62) | Two initial guesses | Moderate | | Brent | Superlinear | Bracketing interval | Very robust |
pythonfrom scipy import integrate def numerical_integration_comparison(f, a: float, b: float) -> dict: """ Compare numerical integration methods. Args: f: Function to integrate a: Lower bound b: Upper bound """ # Adaptive Gaussian quadrature (recommended default) quad_result, quad_error = integrate.quad(f, a, b) # Simpson's rule (fixed-point) n_points = 101 x = np.linspace(a, b, n_points) simps_result = integrate.simpson(f(x), x=x) # Romberg integration romb_result = integrate.romberg(f, a, b) return { "quad": {"value": quad_result, "error_estimate": quad_error}, "simpson": {"value": simps_result, "n_points": n_points}, "romberg": {"value": romb_result}, "recommendation": ( "Use scipy.integrate.quad for most cases. " "It adaptively chooses points for accuracy." ) }
pythonfrom scipy.integrate import solve_ivp def solve_ode_system(f, t_span: tuple, y0: list, method: str = "RK45") -> dict: """ Solve a system of ODEs: dy/dt = f(t, y). Args: f: Right-hand side function f(t, y) t_span: (t_start, t_end) y0: Initial conditions method: Solver method (RK45, RK23, Radau, BDF, LSODA) """ sol = solve_ivp( f, t_span, y0, method=method, dense_output=True, rtol=1e-8, atol=1e-10 ) return { "success": sol.success, "message": sol.message, "t": sol.t, "y": sol.y, "n_evaluations": sol.nfev, "method_used": method } # Example: Lorenz system (chaotic dynamics) def lorenz(t, state, sigma=10, rho=28, beta=8/3): x, y, z = state return [ sigma * (y - x), x * (rho - z) - y, x * y - beta * z ] result = solve_ode_system(lorenz, (0, 50), [1.0, 1.0, 1.0])
Non-stiff problems:
RK45 (default): 4th/5th order Runge-Kutta, adaptive step
RK23: Lower order, useful for less smooth problems
DOP853: High-order, excellent for smooth problems
Stiff problems:
Radau: Implicit Runge-Kutta, good for stiff systems
BDF: Backward differentiation formula (classic stiff solver)
LSODA: Automatically switches between non-stiff and stiff
How to tell if your problem is stiff:
- RK45 takes many tiny steps or fails to converge
- The system has widely separated time scales
- Chemical kinetics, circuit simulations often stiffpythonfrom scipy.optimize import minimize def optimize_with_comparison(f, x0: np.ndarray, bounds: list = None) -> dict: """ Compare optimization methods on a given objective function. Args: f: Objective function to minimize x0: Initial guess bounds: List of (min, max) tuples for each variable """ results = {} # Gradient-free res_nm = minimize(f, x0, method="Nelder-Mead") results["Nelder-Mead"] = {"x": res_nm.x, "fun": res_nm.fun, "nfev": res_nm.nfev} # Gradient-based (quasi-Newton) res_bfgs = minimize(f, x0, method="L-BFGS-B", bounds=bounds) results["L-BFGS-B"] = {"x": res_bfgs.x, "fun": res_bfgs.fun, "nfev": res_bfgs.nfev} return results
1. Rounding error:
Finite precision arithmetic (float64 has ~16 significant digits)
Accumulates in long computations
2. Truncation error:
Error from approximating continuous math with discrete formulas
Example: Finite difference df/dx ~ (f(x+h) - f(x)) / h
3. Conditioning:
Sensitivity of the result to perturbations in input
Condition number quantifies this amplification
Best practice: Always compare your numerical solution against
analytical solutions (when available) or use convergence studies
(refine the discretization and check if the answer converges).When publishing numerical results, report the method used, convergence criteria, error tolerances, grid resolution (for PDEs), and validate against known test cases. Provide code so readers can reproduce your computations.
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 17,581 | 17,053 | -3% | 1 | 1 | 0% | 3,513 | 4,595 | +31% | 0 | 0 | — |
case-03 | fail→pass | 17,185 | 19,584 | +14% | 1 | 1 | 0% | 3,289 | 5,553 | +69% | 0 | 0 | — |
case-12 | pass→pass | 16,833 | 13,245 | -21% | 1 | 1 | 0% | 2,321 | 3,636 | +57% | 0 | 0 | — |
case-02 | fail→fail | 21,600 | 21,114 | -2% | 1 | 1 | 0% | 4,204 | 5,402 | +28% | 0 | 0 | — |
case-04 | pass→pass | 19,217 | 19,901 | +4% | 1 | 1 | 0% | 3,535 | 5,656 | +60% | 0 | 0 | — |
case-05 | pass→pass | 13,558 | 14,093 | +4% | 1 | 1 | 0% | 2,462 | 4,267 | +73% | 0 | 0 | — |
case-06 | pass→pass | 16,491 | 17,702 | +7% | 1 | 1 | 0% | 2,906 | 5,427 | +87% | 0 | 0 | — |
case-07 | fail→fail | 16,581 | 20,292 | +22% | 1 | 1 | 0% | 3,374 | 5,929 | +76% | 0 | 0 | — |
case-13 | pass→pass | 4,168 | 3,180 | -24% | 1 | 1 | 0% | 699 | 2,276 | +226% | 0 | 0 | — |
case-08 | fail→pass | 16,690 | 16,005 | -4% | 1 | 1 | 0% | 2,765 | 4,512 | +63% | 0 | 0 | — |
case-09 | pass→pass | 12,576 | 6,685 | -47% | 1 | 1 | 0% | 2,035 | 2,832 | +39% | 0 | 0 | — |
case-10 | pass→pass | 10,355 | 11,658 | +13% | 1 | 1 | 0% | 1,817 | 3,801 | +109% | 0 | 0 | — |
case-11 | pass→pass | 11,033 | 10,298 | -7% | 1 | 1 | 0% | 1,871 | 3,463 | +85% | 0 | 0 | — |
case-14 | pass→pass | 16,934 | 15,709 | -7% | 1 | 1 | 0% | 2,681 | 4,381 | +63% | 0 | 0 | — |
case-15 | fail→pass | 5,216 | 3,027 | -42% | 1 | 1 | 0% | 845 | 2,272 | +169% | 0 | 0 | — |
case-16 | pass→pass | 10,522 | 7,441 | -29% | 1 | 1 | 0% | 1,676 | 3,213 | +92% | 0 | 0 | — |
case-17 | pass→pass | 17,207 | 12,851 | -25% | 1 | 1 | 0% | 2,716 | 3,839 | +41% | 0 | 0 | — |
case-18 | pass→pass | 6,499 | 3,706 | -43% | 1 | 1 | 0% | 976 | 2,346 | +140% | 0 | 0 | — |
case-19 | pass→pass | 12,064 | 7,417 | -39% | 1 | 1 | 0% | 1,778 | 2,765 | +56% | 0 | 0 | — |
case-20 | pass→pass | 12,731 | 12,281 | -4% | 1 | 1 | 0% | 2,258 | 3,889 | +72% | 0 | 0 | — |
case-21 | pass→pass | 21,340 | 17,243 | -19% | 1 | 1 | 0% | 2,951 | 4,328 | +47% | 0 | 0 | — |
case-22 | fail→pass | 12,572 | 3,162 | -75% | 1 | 1 | 0% | 2,254 | 2,270 | +1% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +18 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.