use of f-solve to solve a set of nonlinear equations in a short time

5 views (last 30 days)
Hi, I'm trying to solve a set of nonlinear equations (about 50 nonlinear equation) by F-solve, but it takes a long time to solve these equations. Since I want to use about 1000 different variables in each loop, many times are required to solve them. Besides, I used the default options and I didn't change it. could you please give me some ways to solve the equation by f-solve in a short time. Best Regards

Answers (1)

John D'Errico
John D'Errico on 3 Oct 2015
Edited: John D'Errico on 3 Oct 2015
Um, so you have a decent sized problem. It takes a long time to solve. No surprise. That you want it to be faster is only a reflection of the fact that we expect everything to happen immediately.
What it looks like to me is that you got fsolve to work on one problem, so then you decided to apply it to thousands of problems. Suddenly, fsolve is not fast enough.
There are several ways to improve the time.
1. Get a faster computer.
2. Use the profile tool to see if your code can be improved. Again, no surprise that sometimes people write code that is less than optimal.
3. Reduce the size of your problem.
4. Apply a tool the parallel toolbox to solve the many problems at once. Of course, this requires a (not cheap) toolbox, and that you learn to use it effectively, AND that you have sufficient cores to gain throughput.
5. Apply a GPU based tool to enhance the speed of some bottleneck point in your code. Again, this requires various things to be true.
There is no magic to be done to fsolve that will suddenly make it run faster. If there were, then it would be the default setting. The problem is not with fsolve here, but with your expectations or with your code.
  1 Comment
milad
milad on 3 Oct 2015
I had this kind of problem before, but when I changed something in my code, the problem was solved in 100 times faster than the other. But in this special case I face with this problem which is related to f-solve options, I think. also my computer has 4 cores which can be used. Anyway thank you for your guidance.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!