Why is fsolve not changing input vector during iterations?
7 ビュー (過去 30 日間)
古いコメントを表示
I'm soling a non-square system of non-linear equations using fsolve, so it is defaulting to 'levenberg-marquardt' algorithm. My function has an input vector and a single scalar output. During each iteration the solver calls my function n number of times, where n is the length of my vector + 1. I would expect it to change the input vector during each call, but it appears to be plugging in the same input vector. I do not understand why it is doing that. I assume it would converge quicker if it changed the input vector during each iteration, but instead it only changes it between each iteration.
Is there something I can do so it only calls the function once during each iteration? Or at least get it to change the input vector during iteration?
1 件のコメント
Matt J
2015 年 1 月 24 日
My function has an input vector and a single scalar output.
Meaning, you have 1 equation and multiple unknowns? If so, you probably should expect difficulties in convergence and, of course, quite unpredictable results...
回答 (1 件)
Matt J
2015 年 1 月 24 日
編集済み: Matt J
2015 年 1 月 24 日
It is doing that as part of the Jacobian calculation, which by default fsolve approximates using finite differences. It is not plugging in the same vector every time. It is making small finite difference increments to each component of the vector which you possibly cannot see because you are only displaying the vector to a limited number of decimal places.
If the analytical calculation of the Jacobian is tractable, you can supply your own calculation using the 'Jacobian' option. That would reduce the number of function evaluations per iteration and also give more accurate results.
参考
カテゴリ
Help Center および File Exchange で Linear Algebra についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!