Why is fsolve not changing input vector during iterations?

11 次查看(过去 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
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
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.
  2 个评论
Matt M
Matt M 2015-1-24
Would the Jacobian be a vector of the same length that would have values of the change that should be made in the next iteration?
Matt J
Matt J 2015-1-24
编辑:Matt J 2015-1-24
The Jacobian is the matrix of partial derivatives of your function, see for example,
However, I would worry first about my comment here.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by