Newton Broyden
Newton Broyden
Guide
JAX Nonlinear System Solvers
High-Performance Newton-Raphson, Trust-Region, and Broyden Methods
Abstract
This comprehensive manual provides detailed documentation for high-performance, JAX-compatible solvers
for nonlinear systems of equations F (x) = 0 in Rn . The implementation leverages JAX’s automatic
differentiation and just-in-time compilation capabilities to achieve both numerical robustness and com-
putational efficiency. This document serves as both a user guide and a theoretical reference, covering
Newton-Raphson methods with Strong Wolfe line search, trust-region methods with dog-leg steps, and
hybrid Broyden methods with automatic fallback strategies.
Contents
1 Introduction 4
1.1 Key Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2 When to Use This Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Mathematical Background 4
2.1 The Nonlinear System Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Newton-Raphson Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Globalization Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3.1 Line Search Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3.2 Trust-Region Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.4 Broyden’s Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Algorithms Overview 5
3.1 Newton with Line Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Trust-Region with Dog-leg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.3 Hybrid Broyden . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
5 API Reference 7
5.1 newton() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.2 broyden_hybrid() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6 Usage Examples 8
6.1 Basic Example: Finding Square Root . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.2 Multidimensional System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
6.3 Stiff System Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
6.4 Large-Scale Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
8 Troubleshooting Guide 10
8.1 Common Issues and Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
8.1.1 Issue: Solver reaches maximum iterations . . . . . . . . . . . . . . . . . . . . . . . . . 10
8.1.2 Issue: NaN or Inf in results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
8.1.3 Issue: Slow convergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
8.2 Debugging Strategies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
9 Advanced Topics 11
9.1 Handling Singular Jacobians . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
9.2 Continuation Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
9.3 Parallel Solution of Multiple Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
10 Theoretical Foundations 12
10.1 Convergence Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
10.2 Trust Region Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
10.3 Line Search Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2
JAX Nonlinear System Solvers - Reference Manual 3
C Troubleshooting Checklist 19
JAX Nonlinear System Solvers - Reference Manual 4
1 Introduction
This module provides high-performance, JAX-compatible solvers for nonlinear systems of equations F (x) = 0
in Rn . The implementation leverages JAX’s automatic differentiation and just-in-time compilation capabil-
ities to achieve both numerical robustness and computational efficiency.
2 Mathematical Background
2.1 The Nonlinear System Problem
Given a function F : D ⊂ Rn → Rn , we seek x∗ such that F (x∗ ) = 0. This arises in:
• Steady-state analysis of dynamical systems
2. J(x∗ ) is nonsingular
where ϕ(α) = 1
2 ∥F (xk + α∆x)∥2 .
(yk − Bk sk )sTk
Bk+1 = Bk + (6)
∥sk ∥2
Theorem 2.2 (Broyden’s Method Convergence). Under similar conditions to Newton’s method, Broyden’s
method achieves superlinear convergence:
∥xk+1 − x∗ ∥
lim =0 (7)
k→∞ ∥xk − x∗ ∥
3 Algorithms Overview
3.1 Newton with Line Search
4.2 Installation
4.3 Configuration
1 import jax
2 # Enable 64 - bit precision ( recommended for numerical stability )
3 jax . config . update ( " jax_enable_x64 " , True )
4
5 # Optional : Set default device
6 jax . config . update ( " jax_default_device " , " gpu " ) # or " cpu "
5 API Reference
5.1 newton()
Parameters:
• fun: Callable Rn → Rn - The nonlinear function F (x)
• x0: jnp.ndarray - Initial guess
• maxiter: int - Maximum iterations (default: 100)
• tol: float - Convergence tolerance on ∥F (x)∥ (default: 1e-8)
• method: str - ’line_search’ or ’trust_region’ (default: ’line_search’)
• delta0: float - Initial trust region radius (default: 1.0)
• alpha0: float - Initial line search step (default: 1.0)
• c1: float - Wolfe sufficient decrease parameter (default: 1e-4)
• c2: float - Wolfe curvature parameter (default: 0.9)
• rho: float - Line search backtracking factor (default: 0.5)
Returns:
• x_root: jnp.ndarray - Approximate solution
• n_iters: int - Number of iterations performed
JAX Nonlinear System Solvers - Reference Manual 8
5.2 broyden_hybrid()
Parameters:
6 Usage Examples
6.1 Basic Example: Finding Square Root
1 import jax
2 import jax . numpy as jnp
3 from nonlin ear_solvers import newton , broyden_hybrid
4
5 # Enable 64 - bit precision
6 jax . config . update ( " jax_enable_x64 " , True )
7
8 # Define system : x ^2 - 2 = 0
9 def f ( x ) :
10 return jnp . array ([ x [0]**2 - 2.0])
11
12 # Initial guess
13 x0 = jnp . array ([1.0])
14
15 # Solve with Newton
16 x_newton , iters_newton = newton (f , x0 )
17 print ( f " Newton : x = { x_newton [0]:.12 f } , iterations = { iters_newton } " )
18
19 # Solve with Broyden
20 x_broyden , iters_broyden = broyden_hybrid (f , x0 )
21 print ( f " Broyden : x = { x_broyden [0]:.12 f } , iterations = { iters_broyden } " )
1 # System of equations :
2 # x ^2 + y ^2 = 4
3 # x - y = 0
4 def system_2d ( x ) :
5 return jnp . array ([
6 x [0]**2 + x [1]**2 - 4.0 ,
7 x [0] - x [1]
8 ])
9
10 x0 = jnp . array ([2.0 , 1.0])
11 x_sol , iters = newton ( system_2d , x0 )
12 print ( f " Solution : x = { x_sol [0]:.6 f } , y = { x_sol [1]:.6 f } " )
13 print ( f " Verification : F ( x ) = { system_2d ( x_sol ) } " )
JAX Nonlinear System Solvers - Reference Manual 9
• Well-conditioned problems
2. Batch Processing
1 # Solve multiple systems in parallel
2 vmap_newton = jax . vmap ( newton , in_axes =( None , 0) )
3 x0_batch = jnp . stack ([ x0_1 , x0_2 , ... , x0_n ])
4 solutions = vmap_newton ( fun , x0_batch )
3. GPU Acceleration
1 # Ensure operations run on GPU
2 with jax . default_device ( jax . devices ( ’ gpu ’) [0]) :
3 x_sol , iters = newton ( fun , x0 )
8 Troubleshooting Guide
8.1 Common Issues and Solutions
8.1.1 Issue: Solver reaches maximum iterations
Symptoms: n_iters == maxiter, large residual norm
Solutions:
9 Advanced Topics
9.1 Handling Singular Jacobians
When the Jacobian becomes singular or ill-conditioned:
2. Levenberg-Marquardt regularization:
1 def l e v e n b e r g_ m a rq u a rd t _ st e p (J , F , lambda_reg =1 e -6) :
2 n = J . shape [0]
3 JtJ = J . T @ J
4 JtF = J . T @ F
5 return - jnp . linalg . solve ( JtJ + lambda_reg * jnp . eye ( n ) , JtF )
JAX Nonlinear System Solvers - Reference Manual 12
3. SVD-based solution:
1 def robust_solve (J , F , tol =1 e -10) :
2 U , S , Vt = jnp . linalg . svd (J , full_matrices = False )
3 S_inv = jnp . where ( S > tol , 1/ S , 0)
4 return - Vt . T @ ( S_inv * ( U . T @ F ) )
10 Theoretical Foundations
10.1 Convergence Analysis
Theorem 10.1 (Newton’s Method Convergence). Let F : D ⊂ Rn → Rn be continuously differentiable in
an open convex set D. Assume:
2. J(x∗ ) is nonsingular
Then ∃δ > 0 such that for x0 with ∥x0 − x∗ ∥ < δ, Newton’s method converges quadratically:
L
∥xk+1 − x∗ ∥ ≤ ∥xk − x∗ ∥2 (8)
2 ∥J(x∗ )−1 ∥
Theorem 10.2 (Broyden’s Method Convergence). Under similar conditions, Broyden’s method achieves
superlinear convergence:
∥xk+1 − x∗ ∥
lim =0 (9)
k→∞ ∥xk − x∗ ∥
JAX Nonlinear System Solvers - Reference Manual 13
For sparse systems, costs can be reduced significantly using sparse linear algebra.
7. Powell, M.J.D. (1970). “A hybrid method for nonlinear equations.” In Numerical Methods for Nonlinear
Algebraic Equations, P. Rabinowitz (ed.), Gordon and Breach.
9. Martinez, J.M. (2000). “Practical quasi-Newton methods for solving nonlinear systems.” Journal of
Computational and Applied Mathematics, 124(1-2), 97-121.
10. Griewank, A. and Walther, A. (2008). Evaluating Derivatives: Principles and Techniques of Algo-
rithmic Differentiation. 2nd Edition. SIAM.
12. Moré, J.J. and Thuente, D.J. (1994). “Line search algorithms with guaranteed sufficient decrease.”
ACM Transactions on Mathematical Software, 20(3), 286-307.
14. Baydin, A.G., Pearlmutter, B.A., Radul, A.A., and Siskind, J.M. (2017). “Automatic differen-
tiation in machine learning: a survey.” Journal of Machine Learning Research, 18(1), 5595-5637.
16. Press, W.H., Teukolsky, S.A., Vetterling, W.T., and Flannery, B.P. (2007). Numerical Recipes:
The Art of Scientific Computing. 3rd Edition. Cambridge University Press.
18. Facchinei, F. and Pang, J.S. (2003). Finite-Dimensional Variational Inequalities and Complementarity
Problems. Springer.
20. Bergou, E., Diouane, Y., and Kungurtsev, V. (2020). “Convergence and complexity of Newton
iteration for operator equations.” Journal of Computational and Applied Mathematics, 372, 112723.
• https://neos-guide.org/
• Interactive examples and solver comparisons
• https://www.mathworks.com/matlabcentral/fileexchange/1322
• MATLAB implementations of various algorithms
• https://docs.scipy.org/doc/scipy/tutorial/optimize.html
• Python implementations and examples
27
28 # Problem sizes to test
29 sizes = [10 , 20 , 50 , 100]
30 results = {}
31
32 for n in sizes :
33 print ( f " \ nSolving Chandrasekhar H - equation with n ={ n } " )
34
35 # Initial guess
36 x0 = jnp . ones ( n )
37
38 # Newton with line search
39 t0 = time . time ()
40 x_newton_ls , iter_newton_ls = newton (
41 lambda x : chandrasekhar_H (x , c =0.9) ,
42 x0 ,
43 method = ’ line_search ’
44 )
45 time_newton_ls = time . time () - t0
46
47 # Newton with trust region
48 t0 = time . time ()
49 x_newton_tr , iter_newton_tr = newton (
50 lambda x : chandrasekhar_H (x , c =0.9) ,
51 x0 ,
52 method = ’ trust_region ’
53 )
54 time_newton_tr = time . time () - t0
55
56 # Broyden
57 t0 = time . time ()
58 x_broyden , iter_broyden = broyden_hybrid (
59 lambda x : chandrasekhar_H (x , c =0.9) ,
60 x0 ,
61 refresh_freq = max (5 , n //10)
62 )
63 time_broyden = time . time () - t0
64
65 # Store results
66 results [ n ] = {
67 ’ newton_ls ’: ( iter_newton_ls , time_newton_ls , x_newton_ls ) ,
68 ’ newton_tr ’: ( iter_newton_tr , time_newton_tr , x_newton_tr ) ,
69 ’ broyden ’: ( iter_broyden , time_broyden , x_broyden )
70 }
71
72 # Print summary
73 print ( f " Newton ( LS ) : { iter_newton_ls } iters , { time_newton_ls :.3 f } sec " )
74 print ( f " Newton ( TR ) : { iter_newton_tr } iters , { time_newton_tr :.3 f } sec " )
75 print ( f " Broyden : { iter_broyden } iters , { time_broyden :.3 f } sec " )
76
77 # Verify solution quality
78 n = 50
79 x_sol = results [ n ][ ’ newton_ls ’ ][2]
80 residual = chandrasekhar_H ( x_sol , c =0.9)
81 print ( f " \ nSolution quality check ( n ={ n }) : " )
82 print ( f " || F ( x ) || _inf = { jnp . max ( jnp . abs ( residual ) ) :.2 e } " )
83 print ( f " || F ( x ) || _2 = { jnp . linalg . norm ( residual ) :.2 e } " )
Listing 1: Chandrasekhar H-equation solver
4 """
5 if x_scale is None :
6 x_scale = jnp . maximum ( jnp . abs ( x0 ) , 1.0)
7 if f_scale is None :
8 f_scale = jnp . maximum ( jnp . abs ( fun ( x0 ) ) , 1.0)
9
10 # Scaled function
11 def fun_scaled ( x_scaled ) :
12 x = x_scaled * x_scale
13 return fun ( x ) / f_scale
14
15 # Solve scaled problem
16 x_scaled_sol , iters = newton ( fun_scaled , x0 / x_scale , ** kwargs )
17
18 # Unscale solution
19 return x_scaled_sol * x_scale , iters
Listing 2: Automatic scaling wrapper
C Troubleshooting Checklist
When encountering issues, work through this checklist:
□ Is x0 in the domain of F ?
□ Is x0 reasonably close to a solution?
□ Try multiple random initial guesses
5. Switch methods
This comprehensive manual provides everything needed to effectively use and understand the
JAX-based nonlinear system solvers. The combination of theoretical background, practical
examples, and extensive references makes it suitable both as a user guide and as a reference for
further study.