fsolve returns a strange value

조회 수: 8 (최근 30일)
Takaaki Itoga
Takaaki Itoga 2016년 1월 27일
댓글: Walter Roberson 2016년 1월 27일
I am trying to solve two non-linear equations with two unknowns, using fsolve. Let me call the system of equations "PFI." When I just take the value of the equation at each x, say y=PFI(x), it returns values like [-1.5,-0.7]. This is not the root, but looks legit. However, when I use fsolve by writing [x0,y,exitflag1]=fsolve(@(x)PFI(x),x0,options), MATLAB returns the following:
[x0,y,exitflag1]=fsolve(@(x)PFI(x),x0,options)
Norm of First-order Trust-region
Iteration Func-count f(x) step optimality radius
0 3 3.49367e+23 0 1
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
selected value of the function tolerance.
<stopping criteria details>
x0 =
1.0000
0.1500
y =
1.0e+11 *
5.9107
0.0000
exitflag1 =
-2
I wonder why f(x) is so huge, and the first-order optimality is zero. The gradient at the initial point is not zero. I would appreciate it any comments. Thank you.
  댓글 수: 1
Takaaki Itoga
Takaaki Itoga 2016년 1월 27일
I would like to add one more thing. This might occur because I call a Fortran subroutine in the equations.

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 1월 27일
fsolve has to invent new points to evaluate at. In the course of doing that, it has encountered a singularity. You probably need to be solving over a bounded region, but fsolve does not permit constraints.
You should be turning on Diagnostics and FunValCheck in the options structure.
  댓글 수: 2
Takaaki Itoga
Takaaki Itoga 2016년 1월 27일
Thank you for your very prompt answer. I found another, probably worse problem. The value of the functions keep changing when I do not change inputs at all. I do not parallelize it, and there is no random variable involved...
Walter Roberson
Walter Roberson 2016년 1월 27일
That sounds as if your Fortran code might have an uninitialized variable.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Fortran with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by