1 Constants and Elementary Functions
(require math/base) | package: math-lib |
For convenience, math/base re-exports racket/math as well as providing the values document below.
In general, the functions provided by math/base are elementary functions, or those functions that can be defined in terms of a finite number of arithmetic operations, logarithms, exponentials, trigonometric functions, and constants. For others, see math/special-functions and math/distributions.
1.1 Constants
If you need more accurate approximations than the following flonums, see, for example, phi.bf and bigfloat->rational.
value
> phi.0 1.618033988749895
value
value
> gamma.0 0.5772156649015329
value
> catalan.0 0.915965594177219
1.2 Functions
procedure
(float-complex? v) → Boolean
v : Any
procedure
x : Number
procedure
(power-of-two? x) → Boolean
x : Real
Examples: | ||||||
|
1.3 Random Number Generation
procedure
(random-natural k) → Natural
k : Integer
procedure
(random-integer a b) → Integer
a : Integer b : Integer
procedure
(random-bits num) → Natural
num : Integer
As an example of use, the significands of the numbers returned by bfrandom are chosen by (random-bits (bf-precision)).
1.4 Measuring Error
procedure
(absolute-error x r) → Real
x : Real r : Real
Examples: | ||||||||||||
|
procedure
(relative-error x r) → Real
x : Real r : Real
This function usually computes (abs (/ (- x r) r)) using exact rationals, but handles non-rational reals such as +inf.0 specially, as well as r = 0.
Examples: | ||||||||||||
|