You are looking at historical revision 26487 of this page. It may differ significantly from its current revision.
mathh
Documentation
Provides access to ISO C math functions in <math.h> that are not defined by the Chicken core. Please refer to your documentation for <math.h> for a description of the various calls.
Math Functions
O, P2 are integer.
N, N1, N2, M are real.
Usage
(include "mathh")
bessel-j0
bessel-j1
bessel-jn
bessel-jn
bessel-y0
bessel-y1
bessel-yn
[procedure] (bessel-j0 N) => real[procedure] (bessel-j1 N) => real
[procedure] (bessel-jn O N) => real
[procedure] (bessel-y0 N) => real
[procedure] (bessel-y1 N) => real
[procedure] (bessel-yn O N) => real
cosh
sinh
tanh
acosh
asinh
atanh
[procedure] (cosh N) => real[procedure] (sinh N) => real
[procedure] (tanh N) => real
[procedure] (acosh N) => real
[procedure] (asinh N) => real
[procedure] (atanh N) => real
hypot
[procedure] (hypot N1 N2) => realgamma
lgamma
[procedure] (gamma N) => real[procedure] (lgamma N) => real
erf
erfc
[procedure] (erf N) => real[procedure] (erfc N) => real
log10
log2
log1p
[procedure] (log10 N) => real[procedure] (log2 N) => real
[procedure] (log1p N) => real
make-log/base
[procedure] (make-log/base N) => (provedure (real) real)Returns a procedure of one argument, the logarithm function for the base N.
ldexp
scalbn
[procedure] (ldexp N P2) => real[procedure] (scalbn N P2) => real
cbrt
[procedure] (cbrt N) => realnextafter
[procedure] (nextafter N M) => realReturns the next N in the direction of M.
fpmod
[procedure] (fpmod N M) => realReturns the modulus of N for M.
modf
[procedure] (modf N) => (values real integer)Returns two values, the integral and fractional components of N.
frexp
[procedure] (frexp N) => (values real real)Returns two values, the fraction and the exponent components of N.
signbit
[procedure] (signbit N) => booleanReturns #t when negative, #f otherwise.
copysign
[procedure] (copysign N M) => realReturns N with same sign as M.
fpclassify
[procedure] (fpclassify N) => symbolReturns a symbol denoting the floating-point kind of N.
- infinite
- nan
- normal
- subnormal
- zero
- unclassified
fpclass
[procedure] (fpclass N) => symbolReturns a symbol denoting the floating-point kind of N.
- positive-infinite
- negative-infinite
- quiet-nan
- signaling-nan
- positive-normal
- negative-normal
- positive-subnormal
- negative-subnormal
- positive-zero
- negative-zero
- unclassified
Math Constants
Common constants, using 'define-constant'. As such they must be textually included.
Usage
(include "mathh-constants")
Constants
- E
- e
- 1/E
- 1/e
- E^2
- e^2
- E^PI/4
- e^(pi/4)
- LOG2E
- log2(e)
- LOG10E
- log10(e)
- LN2
- log(2)
- LN3
- ln(3)
- LNPI
- ln(pi)
- LN10
- log(10)
- 1/LN2
- 1/ln(2)
- 1/LN10
- 1/ln(10)
- PI
- pi
- PI/2
- pi/2
- PI/4
- pi/4
- 1/PI
- 1/pi
- 2/PI
- 2/pi
- 2/SQRTPI
- 2/sqrt(pi)
- SQRTPI
- sqrt(pi)
- PI^2
- pi^2
- DEGREE
- pi/180
- SQRT2
- sqrt(2)
- 1/SQRT2
- 1/sqrt(2)
- SQRT3
- sqrt(3)
- SQRT5
- sqrt(5)
- SQRT10
- sqrt(10)
- CUBERT2
- cubert(2)
- CUBERT3
- cubert(3)
- 4THRT2
- fourthrt(2)
- GAMMA1/2
- gamma(1/2)
- GAMMA1/3
- gamma(1/3)
- GAMMA2/3
- gamma(2/3)
- PHI
- phi
- LNPHI
- ln(phi)
- 1/LNPHI
- 1/ln(phi)
- EULER
- euler
- E^EULER
- e^euler
- SIN1
- sin(1)
- COS1
- cos(1)
- ZETA3
- theta(3
Notes
- The C library call gamma is deprecated in favor of tgamma but not available yet on some platforms, so we use gamma where necessary.
- Some library calls that are not supplied by the platform have rough implementations provided anyway. See Bugs and Limitations.
- The general naming convention is to use the C library call name as the Scheme name. But there are exceptions:
- fmod
- fpmod (Should be in Chicken library?)
- j0
- bessel-j0 (Prefixed to distinguish the names from common variables)
- j1
- bessel-j1
- jn
- bessel-jn
- y0
- bessel-y0
- y1
- bessel-y1
- yn
- bessel-yn
Bugs and Limitations
- The types integer & real refer to the Chicken "core" concept of a number. Support for the full numeric tower is not provided.
- Windows does not provide library calls lgamma, gamma, acosh, asinh, atanh, log2, log1p, erf, erfc, scalbn, cbrt & signbit.
Usable versions of log2, log1p, erf, erfc, scalbn & signbit are provided anyway.
- FreeBSD does not provide the library call log2.
Usable version of log2 is provided anyway.
- The fpclass quiet-nan is only distinguished on Windows.
Author
Version history
- 2.2.2 ; mathh-constants.scm copied to Chicken Repository. Produces shared+static object files.
- 2.2.1
- Better no-install support.
- 2.2.0
- Added acosh, asinh, atanh, erf & erfc. Includes <sunmath.h> on Sun platform for log2.
- 2.1.0
- Added signbit, copysign, nextafter & cbrt.
- 2.0.0
- Chicken 4 release. fpclass and fpclassify are now part of the mathh extension.
License
This code is in the public domain.