Solving systems of non-linear equations

2 次查看(过去 30 天)
I need to solve a system of non-linear equations. For example, I need to solve 10,000 equations, where each individual equation is of the form: 0 = fun(x, c). I want to get a vector X which contains the solution x for each individual equation. In the function, the c is a parameter. There're 10,000 different parameters, so that's why there're 10,000 equations. I have already know how to write a for loop and use fzero to solve for each individual equation with their corresponding c. However, that's too slow. Is there a better way to use "fsolve" to solve this systems of nonlinear equations?

采纳的回答

Walter Roberson
Walter Roberson 2019-6-8
No, there is no better way in the general case.
You can create a single function that calculates the 10000 different values, and you can ask fsolve() to work on it, passing in a vector of 10000 starting values. fsolve() would see this as-if it were a problem with 10000 inter-related variables, and it would spend time building the 10000 by 10000 gradient at each step, trying to figure out how to solve all of the equations as-if each equation depended on every variable. This might produce solutions, but it is not going to produce solutions efficiently.
In some cases you can use calculus to analyze the equation with regards to variable c and get hints about where the solution must be based upon the value of c. For multinomials (polynomials extended to multiple variables) this can be very effective. For example, the family fun(x,c) = x^2 + c*x + 1 easily reduces down to a pair of roots in terms of c, and then you can substitute in the list of c values to get the list of roots without having to solve each one individually.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Systems of Nonlinear Equations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by