root_find_system
root_find_system(f, jacobian, first_guess, tolerance=None, max_iterations=None)Solve a system of nonlinear equations.
Solves F(x) = 0 for a vector-valued F with the ported Numerics multivariate Newton-Raphson method, iterating x_(n+1) = x_n - J(x_n)^-1 F(x_n).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| f | callable | The system of equations: a function taking a sequence of numbers and returning a sequence of numbers of the same length. | required |
| jacobian | callable | The Jacobian of f: a function taking the same sequence and returning the square matrix of partial derivatives (a sequence of rows, or a 2-D array), one ROW per equation. |
required |
| first_guess | array_like | The starting vector; its length fixes the dimension of the system. | required |
| tolerance | float | The convergence tolerance, applied to both the step size and the residual. Left unset, the ported solver’s own default (1e-8) applies. | None |
| max_iterations | int | The iteration cap; the search raises if it is reached. Left unset, the ported solver’s own default (1000) applies. | None |
Returns
| Name | Type | Description |
|---|---|---|
| numpy.ndarray | The root, the length of first_guess. |
Examples
>>> import corehydropy as ch
>>> f = lambda v: [3 * v[0] + v[1] - 9, v[0] + 2 * v[1] - 8]
>>> j = lambda v: [[3, 1], [1, 2]]
>>> ch.root_find_system(f, j, first_guess=[0, 0]).round(6)
array([2., 3.])