Skip to main content

numra_nonlinear/
lib.rs

1#![allow(clippy::single_match)]
2
3//! Nonlinear solvers for Numra.
4//!
5//! This crate provides iterative methods for solving systems of nonlinear equations:
6//!
7//! - **Newton-Raphson** with line search for globalization
8//! - Support for both analytical and numerical (finite difference) Jacobians
9//!
10//! # Example
11//!
12//! ```rust
13//! use numra_nonlinear::{Newton, NewtonOptions, NonlinearSystem};
14//!
15//! // Solve x^2 = 2 (find sqrt(2))
16//! struct SquareRoot;
17//!
18//! impl NonlinearSystem<f64> for SquareRoot {
19//!     fn dim(&self) -> usize { 1 }
20//!     fn eval(&self, x: &[f64], f: &mut [f64]) {
21//!         f[0] = x[0] * x[0] - 2.0;
22//!     }
23//! }
24//!
25//! let solver = Newton::default_solver();
26//! let result = solver.solve(&SquareRoot, &[1.5]).unwrap();
27//! assert!((result.x[0] - std::f64::consts::SQRT_2).abs() < 1e-10);
28//! ```
29//!
30//! Author: Moussa Leblouba
31//! Date: 8 February 2026
32//! Modified: 2 May 2026
33
34pub mod line_search;
35pub mod newton;
36
37pub use line_search::{wolfe_line_search, LineSearchError, LineSearchResult, WolfeOptions};
38pub use newton::{newton_solve, Newton, NewtonOptions, NewtonResult, NonlinearSystem};
39pub use numra_linalg::LinalgError;