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 Center および File ExchangeFortran with MATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by