Re: continued fractions
- From: Jonah Thomas <jethomas5@xxxxxxxxx>
- Date: Sun, 29 Nov 2009 09:33:11 -0500
Thank you for replying! I think this is the first reply I've had on
these concepts.
anton@xxxxxxxxxxxxxxxxxxxxxxxxxx (Anton Ertl) wrote:
Jonah Thomas <jethomas5@xxxxxxxxx> writes:
Second point. The Forth */ does not round. Its division truncates.
Or floors. You can approximate a rounding */ as follows:
: */r ( n1 n2 n3 -- n4 )
>r m* r@ 2/ m+ r> fm/mod nip ;
There will still be a little bias if the divisor is odd, though. You
could correct for that by adding (or, for negative divisors,
subtracting) 1 about half of the time.
Yes, you can make a rounding version of */ . I've never heard of anybody
using one. I wrote one in Forth a long time ago and never used it except
for testing. It improved the result on average by half a bit. It was
written in Forth which at that time was considerably slower than */
written in assembler.
I'd expect the difference to be somewhat less important for 32-bit or
64-bit systems than for 16-bit. While you will on average use smaller
numbers more often than larger numbers, still you have the opportunity
to use larger numbers for which half a bit improvement is less important
than usual.
I claim that continued-fraction results will be less optimal for */ than
they would be for arithmetic that rounds, and so other solutions might
be better for */ . I gave some examples that I say give better results
for pi in 16-bits with */ .
Even for arithmetic that rounds, the continued fraction method is
designed to find the rational approximation which comes closest to the
actual value. I do not yet have a proof or a disproof of the idea that
some other rational approximation might give the best 16-bit value more
often, or the best 32-bit value etc. While a rational approximation that
is significantly worse than the best one cannot give good results, the
pattern of rounding errors might possibly be better for something that
isn't the continued-fraction best -- or possibly it's provable that this
can't happen.
.
- Follow-Ups:
- Re: continued fractions
- From: Elizabeth D Rather
- Re: continued fractions
- From: Bernd Paysan
- Re: continued fractions
- From: Anton Ertl
- Re: continued fractions
- References:
- continued fractions
- From: Hugh Aguilar
- Re: continued fractions
- From: Coos Haak
- Re: continued fractions
- From: Hugh Aguilar
- Re: continued fractions
- From: idknow
- Re: continued fractions
- From: Andrew Haley
- Re: continued fractions
- From: Hugh Aguilar
- Re: continued fractions
- From: Jonah Thomas
- Re: continued fractions
- From: Jonah Thomas
- Re: continued fractions
- From: Anton Ertl
- continued fractions
- Prev by Date: Re: LC53 statistics
- Next by Date: Re: acceptance of forth
- Previous by thread: Re: continued fractions
- Next by thread: Re: continued fractions
- Index(es):
Relevant Pages
|