source: project/wiki/eggref/5/mathh @ 36248

Last change on this file since 36248 was 36248, checked in by Kon Lovett, 2 years ago

easier idx

File size: 7.5 KB
Line 
1[[tags: egg]]
2
3== mathh
4
5[[toc:]]
6
7
8== Documentation
9
10Provides access to ISO C math functions in <math.h> that are not defined by
11the Chicken core. Please refer to your documentation for <math.h> for a
12description of the various calls.
13
14
15=== Math Functions
16
17{{O}} is a {{fixnum}}.
18
19{{P2}} is an {{integer}}.
20
21{{N}}, {{M}}, {{N1}}, {{N2}} are {{float}}.
22
23==== Usage
24
25<enscript language=scheme>
26(import "mathh")
27</enscript>
28
29==== bessel-j0
30==== bessel-j1
31==== bessel-jn
32==== bessel-jn
33==== bessel-y0
34==== bessel-y1
35==== bessel-yn
36
37<procedure>(bessel-j0 N) --> float</procedure>
38<procedure>(bessel-j1 N) --> float</procedure>
39<procedure>(bessel-jn O N) --> float</procedure>
40<procedure>(bessel-y0 N) --> float</procedure>
41<procedure>(bessel-y1 N) --> float</procedure>
42<procedure>(bessel-yn O N) --> float</procedure>
43
44==== cosh
45
46<procedure>(cosh N) --> float</procedure>
47
48==== sinh
49
50<procedure>(sinh N) --> float</procedure>
51
52==== tanh
53
54<procedure>(tanh N) --> float</procedure>
55
56==== acosh
57
58<procedure>(acosh N) --> float</procedure>
59
60==== asinh
61
62<procedure>(asinh N) --> float</procedure>
63
64==== atanh
65
66<procedure>(atanh N) --> float</procedure>
67
68==== hypot
69
70<procedure>(hypot N1 N2) --> float</procedure>
71
72==== gamma
73
74<procedure>(gamma N) --> float</procedure>
75
76==== lgamma
77
78<procedure>(lgamma N) --> float</procedure>
79
80==== erf
81
82<procedure>(erf N) --> float</procedure>
83
84==== erfc
85
86<procedure>(erfc N) --> float</procedure>
87
88==== log10
89
90<procedure>(log10 N) --> float</procedure>
91
92==== log2
93
94<procedure>(log2 N) --> float</procedure>
95
96==== log1p
97
98<procedure>(log1p N) --> float</procedure>
99
100==== log-with-base
101==== log/base
102
103<procedure>(log-with-base N) --> (procedure (float) float)</procedure>
104<procedure>(log/base N) --> (procedure (float) float)</procedure>
105
106Returns a function for the logarithm of base {{N}}.
107
108==== ldexp
109
110<procedure>(ldexp N P2) --> float</procedure>
111
112==== scalbn
113
114<procedure>(scalbn N P2) --> float</procedure>
115
116==== cbrt
117
118<procedure>(cbrt N) --> float</procedure>
119
120==== nextafter
121
122<procedure>(nextafter N M) --> float</procedure>
123
124Returns the next {{N}} in the direction of {{M}}.
125
126==== fpmod
127
128<procedure>(fpmod N M) --> float</procedure>
129
130Returns the modulus of {{N}} for {{M}}.
131
132==== modf
133
134<procedure>(modf N) --> float float</procedure>
135
136Returns two values, the integral and fractional components of {{N}}.
137
138==== modf*
139
140<procedure>(modf* N) --> integer float</procedure>
141
142Returns two values, the integral and fractional components of {{N}}.
143
144==== frexp
145
146<procedure>(frexp N) --> float float</procedure>
147
148Returns two values, the fraction and the exponent components of {{N}}.
149
150==== signbit
151
152<procedure>(signbit N) --> boolean</procedure>
153
154Returns {{#t}} when negative, {{#f}} otherwise.
155
156==== copysign
157
158<procedure>(copysign N M) --> float</procedure>
159
160Returns {{N}} with same sign as {{M}}.
161
162==== fpclassify
163
164<procedure>(fpclassify N) --> symbol</procedure>
165
166Returns a symbol denoting the floating-point kind of {{N}}.
167
168; infinite :
169; nan :
170; normal :
171; subnormal :
172; zero :
173; unclassified :
174
175==== fpclass
176
177<procedure>(fpclass N) --> symbol</procedure>
178
179Returns a symbol denoting the floating-point kind of {{N}}.
180
181; positive-infinite :
182; negative-infinite :
183; quiet-nan :
184; signaling-nan :
185; positive-normal :
186; negative-normal :
187; positive-subnormal :
188; negative-subnormal :
189; positive-zero :
190; negative-zero :
191; unclassified :
192
193
194=== Math Constants (Module)
195
196==== Usage
197
198<enscript language=scheme>
199(import mathh-consts)
200</enscript>
201
202==== Constants
203
204These are all {{float}}.
205
206; e : e
207; 1/e : 1/e
208; e^2 : e^2
209; e^pi/4 : e^(pi/4)
210; log2e : log2(e)
211; log10e : log10(e)
212; ln2 : log(2)
213; ln3 : ln(3)
214; lnpi : ln(pi)
215; ln10 : log(10)
216; 1/ln2 : 1/ln(2)
217; 1/ln10 : 1/ln(10)
218; pi : pi
219; pi/2 : pi/2
220; pi/4 : pi/4
221; 1/pi : 1/pi
222; 2/pi : 2/pi
223; 2/sqrtpi : 2/sqrt(pi)
224; sqrtpi : sqrt(pi)
225; pi^2 : pi^2
226; degree : pi/180
227; sqrt2 : sqrt(2)
228; 1/sqrt2 : 1/sqrt(2)
229; sqrt3 : sqrt(3)
230; sqrt5 : sqrt(5)
231; sqrt10 : sqrt(10)
232; cubert2 : cubert(2)
233; cubert3 : cubert(3)
234; 4thrt2 : fourthrt(2)
235; gamma1/2 : gamma(1/2)
236; gamma1/3 : gamma(1/3)
237; gamma2/3 : gamma(2/3)
238; phi : phi
239; lnphi : ln(phi)
240; 1/lnphi : 1/ln(phi)
241; euler : euler
242; e^euler : e^euler
243; sin1 : sin(1)
244; cos1 : cos(1)
245; zeta3 : theta(3)
246
247
248=== Math Constants (Include)
249
250Common constants, using 'define-constant'. As such they must be textually
251included.
252
253==== Usage
254
255<enscript language=scheme>
256(include "mathh-constants")
257</enscript>
258
259==== Constants
260
261; E : e
262; 1/E : 1/e
263; E^2 : e^2
264; E^PI/4 : e^(pi/4)
265; LOG2E : log2(e)
266; LOG10E : log10(e)
267; LN2 : log(2)
268; LN3 : ln(3)
269; LNPI : ln(pi)
270; LN10 : log(10)
271; 1/LN2 : 1/ln(2)
272; 1/LN10 : 1/ln(10)
273; PI : pi
274; PI/2 : pi/2
275; PI/4 : pi/4
276; 1/PI : 1/pi
277; 2/PI : 2/pi
278; 2/SQRTPI : 2/sqrt(pi)
279; SQRTPI : sqrt(pi)
280; PI^2 : pi^2
281; DEGREE : pi/180
282; SQRT2 : sqrt(2)
283; 1/SQRT2 : 1/sqrt(2)
284; SQRT3 : sqrt(3)
285; SQRT5 : sqrt(5)
286; SQRT10 : sqrt(10)
287; CUBERT2 : cubert(2)
288; CUBERT3 : cubert(3)
289; 4THRT2 : fourthrt(2)
290; GAMMA1/2 : gamma(1/2)
291; GAMMA1/3 : gamma(1/3)
292; GAMMA2/3 : gamma(2/3)
293; PHI : phi
294; LNPHI : ln(phi)
295; 1/LNPHI : 1/ln(phi)
296; EULER : euler
297; E^EULER : e^euler
298; SIN1 : sin(1)
299; COS1 : cos(1)
300; ZETA3 : theta(3)
301
302
303== Notes
304
305* The C library call {{gamma}} is deprecated in favor of {{tgamma}} but not
306available yet on some platforms, so we use {{gamma}} where necessary.
307
308* Some library calls that are not supplied by the platform have rough
309implementations supplied. See {{Bugs and Limitations}}.
310
311* The general naming convention is to use the C library call name as the Scheme
312name. But there are exceptions:
313
314; fmod : fpmod
315; j0 : bessel-j0 (Prefixed to distinguish the names from common variables)
316; j1 : bessel-j1
317; jn : bessel-jn
318; y0 : bessel-y0
319; y1 : bessel-y1
320; yn : bessel-yn
321
322
323== Bugs and Limitations
324
325* Given the notes above not current.
326
327* Support for the full numeric tower is '''not''' provided.
328
329* Windows library calls {{lgamma}}, {{gamma}}, {{acosh}}, {{asinh}},
330{{atanh}}, {{cbrt}} & {{signbit}} are not provided.
331
332* FreeBSD does not provide the library call {{log2}}. A usable {{log2}} is
333supplied.
334
335* The {{fpclass}} {{quiet-nan}} is only distinguished on Windows.
336
337
338== Author
339
340[[/users/kon-lovett|Kon Lovett]]
341[[/users/john cowan|John Cowan]]
342
343
344== Version history
345
346; 4.2.0 : Add {{modf*}}.
347; 4.0.0 : CHICKEN 5 release.
348; 3.4.2 : Fix foreign-declare use. Fix {{fpzero?}}, {{fppositive?}}, {{fpnegative?}}, {{fpcardinal?}} again.
349; 3.4.1 : Remove unneeded dependency.
350; 3.4.0 ; Fix {{fppositive?}}, {{fpnegative?}}, {{fpcardinal?}}, {{fpeven?}}, {{fpodd?}}.
351; 3.3.3 ; Remove Windows {{log2}}, {{log1p}}, {{erf}}, {{erfc}}, {{scalbn}}.
352; 3.3.2 ;
353; 3.3.1 ;
354; 3.3.0 ; Add {{log-with-base}}. Deprecate {{make-log/base}}. Fix {{fprandom}} sign preservation.
355; 3.2.4 ; Add {{fxlog2}}, fix {{fxpow2log2}}.
356; 3.2.3 ; Fix {{4THRT2}}, {{1/LNPHI}}, extend {{1/SQRT2}}.
357; 3.2.2 ; Remove ''inline'' generation for mathh.
358; 3.2.1 ; Add types. Fix {{signbit}} & {{fpclass}}.
359; 3.2.0 ; Fix {{fpodd?}}. Add ''fx-utils.scm''. Extend ''fp-utils.scm''.
360; 3.1.0 ; Added module for ''mathh-constants.scm''.
361; 3.0.0 ; Moved copy of ''mathh-constants.scm'' to {{(chicken-home)}}. Ticket #1327
362; 2.2.6 ; better argvector chicken test
363; 2.2.5 ; argvector chicken support
364; 2.2.4 ;
365; 2.2.3 ; Fix for ticket #630
366; 2.2.2 ; ''mathh-constants.scm'' copied to Chicken Repository. Produces shared+static object files.
367; 2.2.1 : Better ''no-install'' support.
368; 2.2.0 : Added {{acosh}}, {{asinh}}, {{atanh}}, {{erf}} & {{erfc}}. Includes <sunmath.h> on Sun platform for {{log2}}.
369; 2.1.0 : Added {{signbit}}, {{copysign}}, {{nextafter}} & {{cbrt}}.
370; 2.0.0 : Chicken 4 release. {{fpclass}} and {{fpclassify}} are now part of the '''mathh''' extension.
371
372
373== License
374
375This code is in the public domain.
Note: See TracBrowser for help on using the repository browser.