Why is fsolve not changing input vector during iterations?

조회 수: 11 (최근 30일)
Matt M
Matt M 2015년 1월 24일
편집: Matt J 2015년 1월 24일
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