In article <
[email protected]>,
Hans Bezemer <
[email protected]> wrote:
Just some quick doodles concerning this subject:
: fperi-ellipse ( a b -- peri)
fover fover f+ frot frot f- \ (a+b) (a-b)
fdup f* fover fdup f* \ (a+b) (a-b)^2 (a+b)^2
f/ 3 s>f f* \ (a+b) 3h
4 s>f fover f- fsqrt \ (a+b) 3h sqrt(4-3h)
10 s>f f+ f/ \ (a+b) (3h/(10+sqrt(4-3h)))
1 s>f f+ f* pi f* \ pi*(a+b)*(1+(3h/(10+sqrt(4-3h))))
;
( a b -- peri)
: fperi-ellipse-fast 75 s>f f* fswap 120 s>f f* f+ 100 s>f f/ pi f* ;
The first is of Ramanujan - with excellent accuracy. The second has allegedly >better properties than the more familiar 2PI (SQRT((a*a+b*b)/2)) and doesn't >need an expensive FSQRT.
What?
\ --------------------------------
WANT -fp- MARK-TIME
FINIT
: test 1.0E100 1,000,000 0 DO FSQRT 1.0E0 F+ LOOP ;
MARK-TIME test FS. ELAPSED .uS
\ --------------------------------
INCLUDE /tmp/fp.frt
test : ISN'T UNIQUE
2.618033988749894687E0 26701 uS OK
27 ns for a FSQRT with an increment thrown in.
Even with a 1 KWatt machine an .25 per KWh that is
astronomically inexpensive.
Hans Bezemer
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)