For root finding of scalar functions,scipy.optimize.root_scalar
provides a very useful bracket
argument that I can use to set the interval bracketing my root to ensure the root that I find is the one that I want. I want to do the same thing for a vector function of (x1, x2), where the only roots meaningful to me lie between (0, 1) for both variables. However, the vector root finding function in scipy scipy.optimize.root
does not have any way for me to specify bounds, and it doesn't seem that I can specify this as an option to any of the solver methods either.
Are there any ways around this or other packages/functions that do what I want? I'm very new to root finding, but I'm surprised this feature is hard to find since intuitively root finding seems like it would be easier if there are bounds specified. Are there ways I could hack my function to direct one of these algorithms towards the (0, 1) region?
The function scipy.optimize.root_scalar
has the bracket
argument because when the function has a single parameter it is possible to use the bisection algorithm to find the root.
In higher dimensions there is no such bisection algorithm.
Nevertheless, in multiple dimensions it is possible to specify ranges
in scipy.optimize.brute
to limit the search space of the solution.
To find the root of f(x_1, ..., x_n)
, you can try using scipy.optimize.brute
on f(x_1, ..., x_n)^2
since a root is a global minimum of the squared functions.