commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikkel Meyer Andersen <>
Subject Re: [math] Accuracy in root finding with newBrentSolver
Date Tue, 17 Aug 2010 05:11:34 GMT
Hi Juan,

You should also consider transforming to polar coordinates; it might
turn out to be beneficial.

Cheers, Mikkel.

2010/8/17 Juan Barandiaran <>:
> Thanks Mikkel, Ted and Phil for your answers,
> My problem is that yes, the physical consequences of such small errors are
> quite big.
> Because the calculated root is just the input data for a very non-linear
> equation that describes the density of energy generated by an electron in
> its surroundings and changes a lot depending on alfa.
> Just for curiosity I attach a drawing of this density of energy: it should
> be an spiral with a "growing delta wall"  ie. a kind of delta function ever
> smoothly increasing in height but decreasing the width of its base.
> As you can see what I'm getting is a very "hilly" spiral that instead of
> increasing smoothly, goes up and down depending on the error of the alfa
> root found. (also the effect of the sampling step can be seen but that is
> another matter).
> ... and then I have to integrate this 3D function all over the XYZ space to
> get the global energy... which will give me some headaches as a "delta"
> spiral is not the best behaved function to integrate...
> I will explore the possibility of changing variables or transforming the
> function somehow to increase the differences in values surrounding the root.
> By the way, what is R? some mathematical drawing package?
> If I don't get anywhere, I will try using apfloat.
> Thanks and Best Regards,
> 2010/8/15 Ted Dunning <>
>> 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);
>> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message