Skip to main content

Module solve

Module solve 

Source
Expand description

Root finding, polynomial roots and minimization.

The numerical substrate every intersection, projection and extrema algorithm in the kernel sits on. Nothing here is geometric; it is deliberately kept separate so those algorithms are about geometry rather than about convergence.

§What to reach for

  • A root inside a known bracket: brent. Guaranteed to converge, and nearly as fast as Newton in practice.
  • A root with a known derivative and a good starting point: newton, which falls back to bisection whenever a step would leave the bracket. Unsafeguarded Newton diverges on the configurations that matter: a tangential intersection is exactly where the derivative vanishes.
  • Roots of a polynomial up to quartic: roots. Closed form, and the quadratic is written to avoid the cancellation the schoolbook formula suffers.
  • A system of equations: newton_system. Surface projection is two equations in two unknowns; intersection marching is much the same.
  • A minimum without derivatives: minimize.

Structs§

Criteria
Stopping criteria for an iterative solver.
Solution
A solver result: the estimate, the residual there, and how it finished.
SystemSolution
The outcome of solving a system of equations.

Enums§

Convergence
How a solver finished.

Functions§

brent
Find a root of f in [a, b] by Brent’s method.
cubic_roots
Real roots of a x^3 + b x^2 + c x + d.
minimize
Minimize a scalar function on [a, b] without derivatives.
newton
Find a root of f near start, using its derivative, safeguarded by a bracket.
newton_system
Solve f(x) = 0 for a vector x, by damped Newton.
newton_system_2
A two-unknown newton_system, allocation-free.
quadratic_roots
Real roots of a x^2 + b x + c.
roots
The real roots of a polynomial, in increasing order.