changeset 10394:bc475cd49147

avoid div by zero in fzero
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 05 Mar 2010 07:31:19 +0100
parents 7df8f8194c96
children aeb5b1e47978
files scripts/ChangeLog scripts/optimization/fzero.m
diffstat 2 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,7 @@
+2010-03-05  Jaroslav Hajek  <highegg@gmail.com>
+
+	* optimization/fzero.m: Avoid division by zero.
+
 2010-03-04  Jaroslav Hajek  <highegg@gmail.com>
 
 	* optimization/fminbnd.m: Fix tests.
--- a/scripts/optimization/fzero.m
+++ b/scripts/optimization/fzero.m
@@ -287,7 +287,7 @@
 
   ## Check solution for a singularity by examining slope
   if (info == 1)
-    if ((b - a) != 0 && abs ((fb - fa)/(b - a) / slope0) > max (1e6, 0.5/tolx))
+    if ((b - a) != 0 && abs ((fb - fa)/(b - a) / slope0) > max (1e6, 0.5/(eps+tolx)))
       info = -5;
     endif
   endif