Re: High level F** (and/or FEXP)
  Home FAQ Contact Sign in
comp.lang.forth only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: High level F** (and/or FEXP)         

Group: comp.lang.forth · Group Profile
Author: Krishna Myneni
Date: May 15, 2008 20:55

The Beez' wrote:
> I'm still building on top of Brad's FP emulation library and I'm
> coming along quite nicely, doing FSIN, FCOS, FTAN, FLN, FLOG, FASIN,
> FACOS, FATAN, FATAN2.
>
> But I'm still lacking a reasonably reliable F** or FEXP. I found this
> one, but it lacks several definitions:
>
>
> : F** FOVER F0= IF FDROP EXIT ENDIF \ F: ---
>
> FOVER F0< IF FDUP F>S DUP 1 AND ( -- odd? )
> SWAP S>F FOVER F= IF FSWAP FABS FLOG2(X) F*
> F2^X
> ( odd? -- ) IF FNEGATE
> ENDIF EXIT
> ELSE F2DROP DROP -NAN EXIT
> ENDIF
> ENDIF
> FSWAP FLOG2(X) F* F2^X ;
>
> (a) Anybody care to tell me what:
>
> FLOG2(X)
> F2^X
>
> should do?
>

The meaning appears to be

FLOG2(X) ( F: r1 -- r2 ) \ r2 = log base 2 of r1
F2^X ( F: r1 -- r2 ) \ r2 = 2 raised to the r1 power
> (b) Is this word worth persuing or does it have serious limitations
> (like most Taylor series have)?
>

The computation is not based on an approximation. It is based on the
mathematical identities:

log_x (a^b) = b*log_x(a)

and

x^(log_x(a^b)) = a^b

where log_x is logarithm in base x. Here, the word is using x=2.
> Hans Bezemer

Cheers,
Krishna
no comments
diggit! del.icio.us! reddit!