fsolve returns a strange value
Show older comments
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 Comment
Takaaki Itoga
on 27 Jan 2016
Answers (1)
Walter Roberson
on 27 Jan 2016
0 votes
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 Comments
Takaaki Itoga
on 27 Jan 2016
Walter Roberson
on 27 Jan 2016
That sounds as if your Fortran code might have an uninitialized variable.
Categories
Find more on Fortran with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!