From full
Selects and configures nonlinear solvers (Newton, BFGS, Broyden, Anderson, Levenberg-Marquardt) for root-finding, optimization, and least-squares problems, with globalization and convergence diagnostics.
How this skill is triggered — by the user, by Claude, or both
Slash command
/full:nonlinear-solversThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Provide a universal workflow to select a nonlinear solver, configure globalization strategies, and diagnose convergence for root-finding, optimization, and least-squares problems.
CHANGELOG.mdevals/evals.jsonreferences/convergence_diagnostics.mdreferences/globalization_strategies.mdreferences/method_catalog.mdreferences/solver_decision_tree.mdscripts/convergence_analyzer.pyscripts/globalization_advisor.pyscripts/jacobian_diagnostics.pyscripts/residual_monitor.pyscripts/solver_selector.pyscripts/step_quality.pyProvide a universal workflow to select a nonlinear solver, configure globalization strategies, and diagnose convergence for root-finding, optimization, and least-squares problems.
| Input | Description | Example |
|---|---|---|
| Problem type | Root-finding, optimization, least-squares | root-finding |
| Problem size | Number of unknowns | n = 10000 |
| Jacobian availability | Analytic, finite-diff, unavailable | analytic |
| Jacobian cost | Cheap or expensive to compute | expensive |
| Constraints | None, bounds, equality, inequality | none |
| Smoothness | Is objective/residual smooth? | yes |
| Residual history | Sequence of residual norms | 1,0.1,0.01,... |
Is Jacobian available and cheap?
├── YES → Problem size?
│ ├── Small (n < 1000) → Newton (full)
│ └── Large (n ≥ 1000) → Newton-Krylov
└── NO → Is objective smooth?
├── YES → Memory limited?
│ ├── YES → L-BFGS or Broyden
│ └── NO → BFGS
└── NO → Anderson acceleration or Picard
| Problem Type | First Choice | Alternative | Globalization |
|---|---|---|---|
| Small root-finding | Newton | Broyden | Line search |
| Large root-finding | Newton-Krylov | Anderson | Trust region |
| Optimization | L-BFGS | BFGS | Wolfe line search |
| Least-squares | Levenberg-Marquardt | Gauss-Newton | Trust region |
| Bound constrained | L-BFGS-B | Trust-region reflective | Projected |
| Script | Key Outputs |
|---|---|
scripts/solver_selector.py | recommended, alternatives, notes |
scripts/convergence_analyzer.py | converged, convergence_type, estimated_rate, diagnosis |
scripts/jacobian_diagnostics.py | condition_number, jacobian_quality, rank_deficient |
scripts/globalization_advisor.py | strategy, line_search_type, trust_region_type, parameters |
scripts/residual_monitor.py | patterns_detected, alerts, recommendations |
scripts/step_quality.py | ratio, step_quality, accept_step, trust_radius_action |
scripts/solver_selector.pyscripts/globalization_advisor.pyscripts/jacobian_diagnostics.pyscripts/residual_monitor.pyscripts/convergence_analyzer.pyscripts/step_quality.pyUser: My Newton solver for a phase-field simulation is converging very slowly. After 50 iterations, the residual only dropped from 1 to 0.1.
Agent workflow:
python3 scripts/convergence_analyzer.py --residuals 1,0.8,0.6,0.5,0.4,0.3,0.2,0.15,0.12,0.1 --json
python3 scripts/globalization_advisor.py --problem-type root-finding --jacobian-quality ill-conditioned --previous-failures 0 --json
# Select solver for large unconstrained optimization
python3 scripts/solver_selector.py --size 50000 --smooth --memory-limited --json
# Select solver for a small nonlinear least-squares (data-fitting) problem
python3 scripts/solver_selector.py --problem-type least-squares --size 6 --jacobian-available --smooth --json
# Analyze convergence from residual history
python3 scripts/convergence_analyzer.py --residuals 1,0.1,0.01,0.001,0.0001 --tolerance 1e-6 --json
# Diagnose Jacobian quality
python3 scripts/jacobian_diagnostics.py --matrix jacobian.txt --json
# Get globalization recommendation
python3 scripts/globalization_advisor.py --problem-type optimization --jacobian-quality good --json
# Globalization for a distant initial guess (favors trust region)
python3 scripts/globalization_advisor.py --problem-type root-finding --jacobian-quality good --far-from-solution --json
# Monitor residual patterns
python3 scripts/residual_monitor.py --residuals 1,0.8,0.9,0.7,0.75,0.6 --target-tolerance 1e-8 --json
# Evaluate step quality for trust region
python3 scripts/step_quality.py --predicted-reduction 0.5 --actual-reduction 0.4 --step-norm 0.8 --gradient-norm 1.0 --trust-radius 1.0 --json
| Error | Cause | Resolution |
|---|---|---|
problem_size must be positive | Invalid size | Check problem dimension |
problem_size (...) exceeds maximum (...) | Size above 10 billion cap | Re-check the unit/value |
constraint_type must be one of... | Unknown constraint | Use: none, bound, equality, inequality |
problem_type must be one of... | Unknown problem type | Use: root-finding, optimization, least-squares |
residuals must be non-negative | Invalid residual data | Check residual computation |
residuals must be finite | NaN/Inf in residual data | Sanitize residual history |
residual list length (...) exceeds limit (...) | More than 100,000 entries | Downsample the history |
Matrix file not found | Invalid path | Verify Jacobian file exists |
Matrix file exceeds size limit ... | Matrix file too large | Use a smaller / sparser matrix |
| Type | Meaning | Action |
|---|---|---|
| quadratic | Optimal Newton (order p ≈ 2) | Continue, near solution |
| superlinear | Ratios shrinking toward 0 (1 < p < 2); quasi-Newton working | Monitor for stagnation |
| linear | Constant contraction ratio (p ≈ 1); a small constant ratio is fast-linear, not superlinear | May improve with preconditioner |
| sublinear | Too slow (ratio → 1) | Change method or formulation |
| stagnated | No progress | Check Jacobian, preconditioner |
| diverged | Increasing residual | Add globalization, check Jacobian |
| Quality | Condition Number | Action |
|---|---|---|
| good | < 10⁶ | Standard Newton works |
| moderately-conditioned | 10⁶ - 10¹⁰ | Consider scaling |
| ill-conditioned | > 10¹⁰ | Use regularization |
| near-singular | ∞ | Reformulate or use LM |
| Ratio ρ | Quality | Trust Radius |
|---|---|---|
| ρ < 0 | very_poor | Shrink aggressively |
| ρ < 0.25 | marginal | Shrink |
| 0.25 ≤ ρ < 0.75 | good | Maintain |
| ρ ≥ 0.75 | excellent | Expand if at boundary |
Do not trust a "solved" claim until these concrete artifacts are recorded:
convergence_analyzer.py --residuals <history>; recorded convergence_type and estimated_rate, and confirmed converged: true against the actual solver tolerance (not the default 1e-10).residual_monitor.py; recorded patterns_detected and verified it does NOT include diverging, oscillating, plateau, or slow_convergence while still above tolerance.jacobian_diagnostics.py --matrix J.txt and recorded condition_number and jacobian_quality; for an analytic Jacobian, passed --finite-diff-matrix and confirmed finite_diff_error is below ~1e-2 (no "Large discrepancy" note).rank_deficient from jacobian_diagnostics.py is false (or documented why a rank-deficient/near-singular Jacobian is expected and that Levenberg-Marquardt regularization is in use).step_quality.py and recorded the reduction ratio; confirmed accepted steps have ratio >= 0.25 (not very_poor/poor) and that the trust_radius_action matches the recorded ρ.solver_selector.py and globalization_advisor.py recommendations for the stated problem type, size, and Jacobian quality (e.g., large/expensive-Jacobian → Newton-Krylov; least-squares → Levenberg-Marquardt trust region).| Tempting shortcut | Why it's wrong / what to do |
|---|---|
| "The residual ratio is a small constant (~0.1), so it's converging superlinearly." | A constant contraction ratio is linear, not superlinear — convergence_analyzer.py reports this as linear (annotated "fast linear"). Superlinear requires the ratio to tend to zero (order p > 1.2). Don't claim Newton-quality convergence from a flat ratio. |
| "It stopped without erroring, so the solver converged." | Run completion is not convergence. Check converged from convergence_analyzer.py/residual_monitor.py against the real tolerance; a stagnated or plateau result also "stops" but has not solved f(x)=0. |
| "Two iterations look like they're shrinking, so the rate is fine." | Order estimation needs at least 3 strictly decreasing positive residuals; with fewer, convergence_analyzer.py returns unknown/falls back to rate-only. Gather more iterations before quoting a convergence type. |
| "I coded the analytic Jacobian, so it must be right." | A wrong Jacobian still produces some step. Run jacobian_diagnostics.py --finite-diff-matrix and confirm finite_diff_error is small; a "Large discrepancy with finite-diff" note means the analytic Jacobian is buggy, which silently degrades Newton to linear convergence. |
| "Newton diverged, so I'll just shrink the global tolerance and call it close enough." | Divergence (convergence_type: diverged, or diverging pattern) signals a bad step direction or far-from-solution start — add globalization. Run globalization_advisor.py (use --far-from-solution / report failures) and switch to a trust region or damped step instead of loosening the target. |
| "Trust-region step decreased the objective, so accept and expand the radius." | Acceptance and radius growth depend on the reduction ratio ρ, not just sign. step_quality.py only flags expand when ρ ≥ 0.75 and the step hit the boundary; a small positive ρ (marginal) means accept-but-shrink. Use the recorded trust_radius_action. |
| "The Jacobian is large and expensive, but full Newton is the gold standard, so I'll form it anyway." | For n ≥ 1000 or expensive Jacobians, solver_selector.py routes to matrix-free Newton-Krylov (JFNK) precisely because forming/factoring J is infeasible; use Jacobian-vector products plus a preconditioner instead. |
--size (problem size) is validated as a positive integer, bounded at 10 billion--residuals are validated as finite non-negative numbers, capped at 100,000 entries--tolerance and --target-tolerance are validated as finite positive numbers--problem-type and --constraint-type are validated against fixed allowlists--jacobian-quality is validated against a fixed allowlist (good, ill-conditioned, etc.)predicted-reduction, actual-reduction, step-norm, gradient-norm, trust-radius) are validated as finite numbersjacobian_diagnostics.py reads a single matrix file specified by --matrix; no directory traversal beyond the given pathallow_pickle=False to prevent code executionsolver_selector.py, convergence_analyzer.py, jacobian_diagnostics.py, globalization_advisor.py, residual_monitor.py, step_quality.py) with explicit argument listseval(), exec(), or dynamic code generationshell=True)references/solver_decision_tree.md - Problem-based solver selectionreferences/method_catalog.md - Method details and parametersreferences/convergence_diagnostics.md - Diagnosing convergence issuesreferences/globalization_strategies.md - Line search and trust region--problem-type to solver_selector.py with a nonlinear least-squares path (Levenberg-Marquardt / Gauss-Newton); reordered solver selection so problem size dominates high-accuracy and routes large/expensive-Jacobian problems to Newton-Krylov; added --far-from-solution to globalization_advisor.py and surfaced Levenberg-Marquardt as the trust-region type for least-squares; corrected convergence classification so constant-ratio sequences are linear (not superlinear); RFC-8259-safe JSON (no -Infinity); input-validation hardeningnpx claudepluginhub heshamfs/materials-simulation-skills --plugin core-numericalGuides selection of direct/iterative linear solvers for Ax=b, recommends preconditioners, and diagnoses convergence issues in numerical simulations.
Formulates and solves optimization problems — defining decision variables, objective functions, and constraints — and selects appropriate solvers for LP, QP, NLP, or MIP.
Optimizes multi-objective problems using pymoo (NSGA-II/III, MOEA/D) with Pareto-front computation, constraint handling, and standard benchmarks (ZDT, DTLZ).