Hi all, I believe that there is a bug in eps_tolerance implementation. At line 34 of toms748_solve.hpp one can see: return (fabs(a - b) / (std::min)(fabs(a), fabs(b))) <= eps; When both a and b equal zero this condition is evaluated to a false instead of a true. Left hand of condition is NaN and the right one is a floating- point number hence the result is false. Well obviously, a user wants to see true here because the relative length of interval in this case tend to zero.
AMDG On 10/09/2011 06:47 AM, Matwey V. Kornilov wrote:
I believe that there is a bug in eps_tolerance implementation. At line 34 of toms748_solve.hpp one can see:
return (fabs(a - b) / (std::min)(fabs(a), fabs(b))) <= eps;
When both a and b equal zero this condition is evaluated to a false instead of a true. Left hand of condition is NaN and the right one is a floating- point number hence the result is false.
Well obviously, a user wants to see true here because the relative length of interval in this case tend to zero.
What exactly do you mean by "the relative length of the interval tends to zero?" lim_{(a,b)->(0,0)} |a-b| / min(|a|, |b|) doesn't exist. In Christ, Steven Watanabe
This routine checks that the interval is small enough. We check interval that bounds the root that we are looking for. Now, let me consider interval whose lower and upper bounds are equal. In such case we find our root exactly. There is no way to make it more precise. and, actually let a=b=x, lim_{x->0} ((x-x)/min(|x|,|x|)) = lim_{x->0} (0/min(|x|,|x|)) = lim_{x->0} (0) = 0 Steven Watanabe wrote:
What exactly do you mean by "the relative length of the interval tends to zero?"
lim_{(a,b)->(0,0)} |a-b| / min(|a|, |b|)
doesn't exist.
In Christ, Steven Watanabe
On Sun, 09 Oct 2011 19:04:39 +0200, Matwey V. Kornilov
and, actually let a=b=x,
lim_{x->0} ((x-x)/min(|x|,|x|)) = lim_{x->0} (0/min(|x|,|x|)) = lim_{x->0} (0) = 0
I'am not active mathematician, but I believe lim {x->0} (0/x) is 0/0 and thus considered undefined, not 0.
Viatcheslav.Sysoltsev@h-d-gmbh.de wrote:
On Sun, 09 Oct 2011 19:04:39 +0200, Matwey V. Kornilov
wrote: and, actually let a=b=x,
lim_{x->0} ((x-x)/min(|x|,|x|)) = lim_{x->0} (0/min(|x|,|x|)) = lim_{x->0} (0) = 0
I'am not active mathematician, but I believe lim {x->0} (0/x) is 0/0 and thus considered undefined, not 0.
lim 0/x is 0, but the original expression (with a and b) has no limit when a, b -> 0. If we let a = 2x, b = x, for example, we get lim(x->0) x/|x| which is either +1 or -1.
On Mon, Oct 10, 2011 at 3:01 AM,
On Sun, 09 Oct 2011 19:04:39 +0200, Matwey V. Kornilov < matwey.kornilov@gmail.com> wrote:
and, actually let a=b=x,
lim_{x->0} ((x-x)/min(|x|,|x|)) = lim_{x->0} (0/min(|x|,|x|)) = lim_{x->0} (0) = 0
I'am not active mathematician, but I believe lim {x->0} (0/x) is 0/0 and thus considered undefined, not 0.
I haven't run the numbers either, but 0/0 is indeed undefined or Single.NaN if you prefer.
______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**usershttp://lists.boost.org/mailman/listinfo.cgi/boost-users
I haven't been following this thread closely, but I know enough math to say that lim_{x->0} (0/x) is 0. When evaluating a limit, one does not simply substitute the limiting value into the expression. The limit is the value of the expression as the variable gets arbitrarily close but not equal to the limiting value. As x gets arbitrarily close to 0, 0/x remains exactly 0. I have no clue, how this impacts the original issue. Cheers. Curtis Gehman Burlingame, CA On Oct 10, 2011, at 3:17 AM, Michael Powell wrote:
On Mon, Oct 10, 2011 at 3:01 AM,
wrote: On Sun, 09 Oct 2011 19:04:39 +0200, Matwey V. Kornilov wrote: and, actually let a=b=x,
lim_{x->0} ((x-x)/min(|x|,|x|)) = lim_{x->0} (0/min(|x|,|x|)) = lim_{x->0} (0) = 0
I'am not active mathematician, but I believe lim {x->0} (0/x) is 0/0 and thus considered undefined, not 0.
I haven't run the numbers either, but 0/0 is indeed undefined or Single.NaN if you prefer.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
When evaluating a limit, one does not simply substitute the limiting value into the expression. The limit is the value of the expression as the variable gets arbitrarily close but not equal to the limiting value. As x gets arbitrarily close to 0, 0/x remains exactly 0. I have no clue, how this impacts the original issue.
Just to say that the mathematical definition of 0/0 is irrelevant in this context - the point is that if both ends of the range are zero - then our root finding has converged. The evaluation of 0/0 in this code was a mistake, pure and simple. John.
I haven't been following this thread closely, but I know enough math to say that lim_{x->0} (0/x) is 0. When evaluating a limit, one does not simply substitute the limiting value into the expression. The limit is the value of the expression as the variable gets arbitrarily close but not equal to the limiting value. As x gets arbitrarily close to 0, 0/x remains exactly 0. I have no clue, how this impacts the original issue.
Cheers.
Curtis Gehman Burlingame, CA
Another way of looking at it is to use L'Hopital's rule: lim_{x->0} ((x-x)/min(|x|,|x|)) => lim_{x->0} ((x-x)/x) => d/dx(x-x) / d/dx(x) => (1-1) / 1 => 0 Like Curtis says, no idea exactly what that means for the original question. Jerry
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Jonathan Franklin Sent: Monday, October 10, 2011 11:37 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] math tools roots
On Mon, Oct 10, 2011 at 2:51 PM, Jerry
wrote: Another way of looking at it is to use L'Hopital's rule:
0/x is not an indeterminate form, so you can't apply l'Hopital's rule. If fact, there is no need since 0/x = 0 for all x != 0.
Whoa - I fear you mathematicians are getting over-excited! This is C++ and floating-point and NaN (with arbitrary definitions of behaviour). Entirely different rules apply! A more interesting question might be how to avoid going round the loop too many times when a and b are getting so near to zero that they are becoming ill-defined in the floating-point type in use. But let's not go there now ;-) Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com
I believe that there is a bug in eps_tolerance implementation. At line 34 of toms748_solve.hpp one can see:
return (fabs(a - b) / (std::min)(fabs(a), fabs(b))) <= eps;
When both a and b equal zero this condition is evaluated to a false instead of a true. Left hand of condition is NaN and the right one is a floating- point number hence the result is false.
Will fix: can you please file a bug report at svn.boost.org so I don't forget? Thanks, John.
participants (10)
-
curtis2006@mac.com
-
Jerry
-
John Maddock
-
Jonathan Franklin
-
Matwey V. Kornilov
-
Michael Powell
-
Paul A. Bristow
-
Peter Dimov
-
Steven Watanabe
-
Viatcheslav.Sysoltsev@h-d-gmbh.de