Why the answer is wrong ?
조회 수: 3 (최근 30일)
이전 댓글 표시
The answers are 1 and 1 instead -1 and 1, why ?
>> fsolve(@(x) [x.^2-1], ones(2,1))
Equation solved at initial point.
fsolve completed because the vector of function values at the initial point is near zero as measured by the default value of the function tolerance, and the problem appears regular as measured by the gradient.
ans =
1
1
댓글 수: 0
답변 (1개)
Walter Roberson
2012년 12월 26일
fsolve() does not look for all possible answers: it just finds candidate answers.
If you were to use (say) [-5, 5] as your initial point, you would be more likely to get -1 and 1 out, but it would not be guaranteed.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!