From: John Tapsell <johnflux@gmail.com>
To: Ealdwulf Wuffinga <ealdwulf@googlemail.com>
Cc: Christian Couder <chriscool@tuxfamily.org>,
Git List <git@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>
Subject: Re: Generalised bisection
Date: Thu, 12 Mar 2009 06:45:43 +0000 [thread overview]
Message-ID: <43d8ce650903112345x3d40b70ap7e4c0f8c7d0b6069@mail.gmail.com> (raw)
In-Reply-To: <efe2b6d70903111515p2b9f656bp186d0b3cc7ae483d@mail.gmail.com>
2009/3/11 Ealdwulf Wuffinga <ealdwulf@googlemail.com>:
> [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@gmail.com> 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
next prev parent reply other threads:[~2009-03-12 6:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-09 1:40 Generalised bisection Ealdwulf Wuffinga
2009-03-10 7:08 ` Christian Couder
2009-03-11 8:59 ` Ealdwulf Wuffinga
2009-03-11 9:35 ` John Tapsell
2009-03-11 12:05 ` Johannes Schindelin
2009-03-11 12:08 ` John Tapsell
2009-03-11 13:04 ` Johannes Schindelin
2009-03-11 13:24 ` John Tapsell
2009-03-11 22:14 ` Ealdwulf Wuffinga
2009-03-11 22:15 ` Ealdwulf Wuffinga
2009-03-12 6:45 ` John Tapsell [this message]
2009-03-12 10:55 ` Johannes Schindelin
2009-03-12 18:02 ` Steven Tweed
2009-03-13 10:00 ` Ealdwulf Wuffinga
2009-03-13 12:49 ` Ealdwulf Wuffinga
2009-03-13 15:19 ` Steven Tweed
2009-03-15 19:16 ` Ealdwulf Wuffinga
2009-03-16 10:29 ` Steven Tweed
2009-03-16 10:37 ` John Tapsell
2009-03-16 22:47 ` Ealdwulf Wuffinga
2009-03-16 22:08 ` Ealdwulf Wuffinga
2009-03-13 9:58 ` Ealdwulf Wuffinga
2009-03-13 10:55 ` Johannes Schindelin
2009-03-13 12:42 ` John Tapsell
2009-03-13 13:56 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43d8ce650903112345x3d40b70ap7e4c0f8c7d0b6069@mail.gmail.com \
--to=johnflux@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=ealdwulf@googlemail.com \
--cc=git@vger.kernel.org \
--cc=mingo@elte.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).