I am trying to solve for a system of linear equations (say solving for 500 variables, 500 equations)using NSolve. I found that its taking a longer time than expected. Its taking hours to solve this problem. Why is it so? But it is solving them correctly and I am getting convincing solutions after it solved them, but it will be meaningful only if it solves faster.
The compiler reads the code, making up matrices, etc. faster, and comes to the Solve or NSolve statement (I checked this by inserting several output statements - without ; ). Once it starts reading Solve/NSolve statement, the following output statements are executed after many minutes of time, sometimes goes to an hour or so.
For more detailed view, please read further:
I am using two methods to create a set of linear equations.
1st method - I use simple power series method to calculate the A values in A*X+B=0, and I am using arrays to store the values. Previously I was using functions and I was calling repeatedly functions inside Do loops, and I realized that I can save time there and so I created arrays and stored all the values thus computed in the loop and use it later whenever needed.
Here I was able to solve them faster (solves in 30 seconds to maximum of 3 minutes) up to a point, i.e.,less nodal points (power series - computations of coefficients A will take time and related computations thus require more time).
2nd method: I am using splines to calculate those coefficient A in A*X+B=0, and I verified (by inserting output statements), that the compiler reaches to the NSolve statement faster (about the same time - about a minute or a couple) but it takes longer time to solve the thus formed equations set.
Any Ideas? Please suggest me how to overcome this deficiency.
University of Oklahoma