/** * Nonlinear system solver: `fsolve` (damped Newton with a backtracking line * search) for `F: R^n -> R^n`. Complements the scalar open root-finders * (`./open-root-finders.ts`) and reuses the two Phase 1 foundations: * `numericJacobian` (Task 1, central-difference Jacobian) and `linsolve` * (`../typed/numeric.ts`, LU with partial pivoting) for the Newton step. * * @packageDocumentation */ import { type VectorField } from './numeric-jacobian.js'; type f64 = number; type i32 = number; /** Options for `fsolve` / `root`. */ export interface FsolveOptions { /** Absolute tolerance on max|F_i(x)| for convergence (default 1e-10). */ tol?: f64; /** Maximum Newton iterations (default 100). */ maxIter?: i32; } /** * Solve `F(x) = 0` for `F: R^n -> R^n` via damped Newton's method. * * At each iterate: compute `J = numericJacobian(F, x)`, solve the Newton * step `J * delta = -F(x)` via `linsolve`, then backtrack — try * `lambda = 1, 1/2, 1/4, ...` (up to ~20 halvings) and take the largest * `lambda` for which `||F(x + lambda*delta)||_2 < ||F(x)||_2`, falling back * to `lambda = 1` (a plain Newton step) if no halving improves the residual. * Update `x <- x + lambda*delta` and repeat until * `max_i |F_i(x)| < tol` (converged) or `maxIter` is exhausted. * * @param F - Vector field whose root is sought (`F(x) = 0`) * @param x0 - Initial guess (length n) * @param opts - Options (tol, maxIter) * @returns Approximate solution vector x with F(x) ~ 0 * @throws If the Jacobian is singular (`linsolve` fails) or Newton fails to * converge within `maxIter` iterations. * * @example * fsolve((v) => [v[0] ** 2 - v[1], v[0] + v[1] - 2], [0.5, 0.5]) // => ~[1, 1] */ export declare function fsolve(F: VectorField, x0: readonly number[], opts?: FsolveOptions): number[]; /** Alias for `fsolve` — `root(F, x0)` solves `F(x) = 0`. */ export declare const root: typeof fsolve; export {}; //# sourceMappingURL=fsolve.d.ts.map