[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #53991] Octave crashes using fsolve when x0 is
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #53991] Octave crashes using fsolve when x0 is a stationary point |
Date: |
Tue, 19 Jun 2018 17:44:01 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 |
Follow-up Comment #5, bug #53991 (project octave):
@Marco: Can you review this patch for fsolve?
diff -r b7db401e1a99 scripts/optimization/fsolve.m
--- a/scripts/optimization/fsolve.m Tue Jun 19 09:18:44 2018 -0700
+++ b/scripts/optimization/fsolve.m Tue Jun 19 14:23:19 2018 -0700
@@ -304,10 +304,18 @@ function [x, fvec, info, output, fjac] =
## Get trust-region model (dogleg) minimizer.
if (useqr)
+ if (abs (r) < macheps)
+ info = -2;
+ break;
+ endif
qtf = q'*fvec;
s = - __dogleg__ (r, qtf, dg, delta);
w = qtf + r * s;
else
+ if (abs (fjac) < macheps)
+ info = -2;
+ break;
+ endif
s = - __dogleg__ (fjac, fvec, dg, delta);
w = fvec + fjac * s;
endif
If the Jacobian is very small this stops fsolve before calling __dogleg__ with
a zero value for the first argument which would eventually lead to an
ill-conditioned matrix.
One question, should the test be for any component of fjac or should we be
taking the norm first? In other words, this
if (any (abs (fjac(:)) < macheps))
info = -2;
break;
endif
OR
if (norm (fjac) < macheps)
info = -2;
break;
endif
I expect it is something like the latter. The first thing that the
__dogleg__routine does is calculate
x = fjac \ fvec;
If fjac is a vector or matrix having a zero would be okay. Only an all zero
array would be a problem.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?53991>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/