Re: Generalised bisection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/3/11 Ealdwulf Wuffinga <ealdwulf@xxxxxxxxxxxxxx>:
> [John will get this twice, sorry; not used to this mail interface yet.]
>
> On Wed, Mar 11, 2009 at 9:35 AM, John Tapsell <johnflux@xxxxxxxxx> wrote:
>
>> mpmath might be the more annoying dependency - what functions do you
>> use from it?  Could they trivially be reimplemented?
>
> What I use is the multiprecision floating point number class. doubles
> don't seem to be long enough.

Hmm, really really?  Sometimes this sort of thing can be fixed by just
readjusting the formulas.  What formulas are you using that require
more precision than doubles?

> The reason for using mpmath rather than the more  widespread GMP (and
> its python wrapper gmpy) is that the latter only supports
> integer powers, whereas BBChop needs fractional powers.
>
> So, it might be possible to switch to gmpy,  or some other widespread
> library,  by implementing a pow() which supports fractional powers.
> I think I only use the normal arithmetic operators, log, and pow, so
> in principle those could be reimplemented, to eliminate the dependency
> altogether.
> It seems a little bit of a waste of time, though.

A little bit of math trickery helps here :-)

y =  x^b

log(y) = log(x^b) = b * log(x)
e^log(y) = e^(b log(x))

y = exp(b * log(x))

So as long as you have 'exp' and 'log' functions, you can raise x to
the power of b, even if b is fractional.

Just to prove it, square root of 2 is:

$ echo "e(0.5*l(2))" | bc -l
1.41421356237309504878

John
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux