commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Dunning <>
Subject Re: [math] Accuracy in root finding with newBrentSolver
Date Sun, 15 Aug 2010 18:14:55 GMT
I think that you need to consider what your problem really is.  Is this
equation even as accurate as 10^-300?  What will the physical consequences
of such small errors be?

If you really think you need to solve this numerically, then I see that you
have two choices:

a) use some unbounded precision package such as

Keep in mind that the cost of taking powers and using trig functions is
likely to scale *very* badly with increased precision.

b) restate your problem in a scaled form so that the difference is apparent
with normal floating point.  The most common way to do this is by using logs
and asymptotic formulae.  This could dramatically improve your situation,
but will require some pretty tricky manipulation of your problem.

To misquote the Bard, the problem dear Brutus lies not in our numerics, but
in your formula.

On Thu, Aug 12, 2010 at 6:15 PM, Juan Barandiaran <> wrote:

> Hi, I'm working in a theoretical physics problem in which I have to find
> the
> roots of a function for every point in x,y,z.
> I can bracket quite precisely where every root will be found and I know the
> exact solution for many points:
> For every point (x= 1, y= n*2*PI, z= 0) the root is in -n*2*PI.
> I have been using the newBrentSolver function, but to my surprise, even
> when
> I set the Accuracy settings to very
> small values and the MaxIterationCount to Integer.MAX_VALUE I get an error
> of 1.427E-5 (too much).
> The function to be solved is alfa in
> :
> alfa+Math.sqrt(Math.pow(x-Math.cos(alfa),2.0)+Math.pow(y-Math.sin(alfa),2.0)+z*z);

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message