MATLAB has two methods to solve a nonlinear equation:
Therefore, one can use the following methods to solve a system of n nonlinear independent equations:
- Use a loop to solve the equations separately using
fzero - Use a loop to solve the equations separately using
fsolve - Use
fsolveto solve them together
My intuition would be that:
- A loop method is faster than a single system for large
nas complexity (gradient calculation) is 0(n^2) - A loop may be slower for small
nas a loop has a high overhead in MATLAB and there may be some constant startup time fzerois faster thanfsolveas it is specifically made for a single nonlinear equation.
Question: What is the fastest method to a system of n nonlinear independent equations? Are there other methods? Which options should be used to speed up the process?
Example problem: (may be used to benchmark different answers)
x_i^2 = 1
with i between 1 and n
Related threads