1
<?xml version="1.0" encoding="ISO8859-1"?>
5
$Id: math.xml,v 1.4 2005/04/29 07:57:29 michael Exp $
6
This file is part of the FPC documentation.
7
Copyright (C) 1997, by Michael Van Canneyt
9
The FPC documentation is free text; you can redistribute it and/or
10
modify it under the terms of the GNU Library General Public License as
11
published by the Free Software Foundation; either version 2 of the
12
License, or (at your option) any later version.
14
The FPC Documentation is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Library General Public License for more details.
19
You should have received a copy of the GNU Library General Public
20
License along with the FPC documentation; see the file COPYING.LIB. If not,
21
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22
Boston, MA 02111-1307, USA.
26
<short>Additional mathematical routines.</short>
27
<!-- \FPCexampledir{mathex} -->
30
This document describes the <file>math</file> unit. The <var>math</var> unit
31
was initially written by Florian Klaempfl. It provides mathematical
32
functions which aren't covered by the system unit.
35
This chapter starts out with a definition of all types and constants
36
that are defined, after which an overview is presented of the available
37
functions, grouped by category, and the last part contains a
38
complete explanation of each function.
41
The following things must be taken into account when using this unit:
44
<li>This unit is compiled in Object Pascal mode so all <var>integers</var> are 32 bit.</li>
45
<li> Some overloaded functions exist for data arrays of integers and
46
floats. When using the address operator (<var>@</var>) to pass an array of
47
data to such a function, make sure the address is typecasted to the
48
right type, or turn on the 'typed address operator' feature. failing to
49
do so, will cause the compiler not be able to decide which function you
55
<topic name="MinMaxRoutines">
56
<short>Min/max determination</short>
59
Functions to determine the minimum or maximum of numbers:
62
<th><td>Name</td><td>Description</td></th>
63
<tr><td><link id="max"/></td><td>Maximum of 2 values</td></tr>
64
<tr><td><link id="maxIntValue"/></td><td>Maximum of an array of integer values</td></tr>
65
<tr><td><link id="maxvalue"/></td><td>Maximum of an array of values</td></tr>
66
<tr><td><link id="min"/></td><td>Minimum of 2 values</td></tr>
67
<tr><td><link id="minIntValue"/></td><td>Minimum of an array of integer values</td></tr>
68
<tr><td><link id="minvalue"/></td><td>Minimum of an array of values</td></tr>
73
<topic name="AngleConversionRoutines">
74
<short>Angle unit conversion</short>
77
Routines to convert angles between different angle units.
80
<th><td>Name</td><td>Description</td></th>
81
<tr><td><link id="cycletorad"/></td><td>convert cycles to radians</td></tr>
82
<tr><td><link id="degtograd"/></td><td>convert degrees to grads</td></tr>
83
<tr><td><link id="degtorad"/></td><td>convert degrees to radians</td></tr>
84
<tr><td><link id="gradtodeg"/></td><td>convert grads to degrees</td></tr>
85
<tr><td><link id="gradtorad"/></td><td>convert grads to radians</td></tr>
86
<tr><td><link id="radtocycle"/></td><td>convert radians to cycles</td></tr>
87
<tr><td><link id="radtodeg"/></td><td>convert radians to degrees</td></tr>
88
<tr><td><link id="radtograd"/></td><td>convert radians to grads</td></tr>
93
<topic name="TrigoniometricRoutines">
94
<short>Trigoniometric functions</short>
97
<th><td>Name</td><td>Description</td></th>
98
<tr><td><link id="arccos"/></td><td>calculate reverse cosine</td></tr>
99
<tr><td><link id="arcsin"/></td><td>calculate reverse sine</td></tr>
100
<tr><td><link id="arctan2"/></td><td>calculate reverse tangent</td></tr>
101
<tr><td><link id="cotan"/></td><td>calculate cotangent</td></tr>
102
<tr><td><link id="sincos"/></td><td>calculate sine and cosine</td></tr>
103
<tr><td><link id="tan"/></td><td>calculate tangent</td></tr>
108
<topic name="HyperbolicRoutines">
109
<short>Hyperbolic functions</short>
112
<th><td>Name</td><td>Description</td></th>
113
<tr><td><link id="arcosh"/></td><td>caculate reverse hyperbolic cosine</td></tr>
114
<tr><td><link id="arsinh"/></td><td>caculate reverse hyperbolic sine</td></tr>
115
<tr><td><link id="artanh"/></td><td>caculate reverse hyperbolic tangent</td></tr>
116
<tr><td><link id="cosh"/></td><td>calculate hyperbolic cosine</td></tr>
117
<tr><td><link id="sinh"/></td><td>calculate hyperbolic sine</td></tr>
118
<tr><td><link id="tanh"/></td><td>calculate hyperbolic tangent</td></tr>
123
<topic name="ExpLogRoutines">
124
<short>Exponential and logarithmic functions</short>
127
<th><td>Name</td><td>Description</td></th>
128
<tr><td><link id="intpower"/></td><td>Raise float to integer power</td></tr>
129
<tr><td><link id="ldexp"/></td><td>Calculate $2^p x$</td></tr>
130
<tr><td><link id="lnxp1"/></td><td>calculate <var>log(x+1)</var></td></tr>
131
<tr><td><link id="log10"/></td><td>calculate 10-base log</td></tr>
132
<tr><td><link id="log2"/></td><td>calculate 2-base log</td></tr>
133
<tr><td><link id="logn"/></td><td>calculate N-base log</td></tr>
134
<tr><td><link id="power"/></td><td>raise float to arbitrary power</td></tr>
139
<topic name="NumberConversionRoutines">
140
<short>Number converting</short>
143
<th><td>Name</td><td>Description</td></th>
144
<tr><td><link id="ceil"/></td><td>Round to infinity</td></tr>
145
<tr><td><link id="floor"/></td><td>Round to minus infinity</td></tr>
146
<tr><td><link id="frexp"/></td><td>Return mantissa and exponent</td></tr>
151
<topic name="StatisticalRoutines">
152
<short>Statistical functions</short>
155
<th><td>Name</td><td>Description</td></th>
156
<tr><td><link id="mean"/></td><td>Mean of values</td></tr>
157
<tr><td><link id="meanandstddev"/></td><td>Mean and standard deviation of values</td></tr>
158
<tr><td><link id="momentskewkurtosis"/></td><td>Moments, skew and kurtosis</td></tr>
159
<tr><td><link id="popnstddev"/></td><td>Population standarddeviation </td></tr>
160
<tr><td><link id="popnvariance"/></td><td>Population variance</td></tr>
161
<tr><td><link id="randg"/></td><td>Gaussian distributed randum value</td></tr>
162
<tr><td><link id="stddev"/></td><td>Standard deviation</td></tr>
163
<tr><td><link id="sum"/></td><td>Sum of values</td></tr>
164
<tr><td><link id="sumofsquares"/></td><td>Sum of squared values</td></tr>
165
<tr><td><link id="sumsandsquares"/></td><td>Sum of values and squared values</td></tr>
166
<tr><td><link id="totalvariance"/></td><td>Total variance of values</td></tr>
167
<tr><td><link id="variance"/></td><td>variance of values</td></tr>
172
<topic name="GeometricalRoutines">
173
<short>Geometrical functions</short>
176
<th><td>Name</td><td>Description</td></th>
177
<tr><td><link id="hypot"/></td><td>Hypotenuse of triangle</td></tr>
178
<tr><td><link id="norm"/></td><td>Euclidian norm</td></tr>
183
<element name="Float">
184
<short>Float type used in all calls</short>
186
All calculations are done with the Float type. This allows to
187
recompile the unit with a different float type to obtain a
188
desired precision. The pointer type <link id="PFloat"/>
189
is used in functions that accept an array of values of arbitrary length.
193
<element name="PFloat">
194
<short>Pointer to <link id="Float"/> type.</short>
197
<element name="TPaymentTime">
198
<short>Type used in financial (interest) calculations.</short>
200
<element name="TPaymentTime.PTEndOfPeriod">
201
<short>End of period.</short>
203
<element name="TPaymentTime.PTStartOfPeriod">
204
<short>Start of period.</short>
207
<element name="EInvalidArgument">
208
<short>Exception raised when invalid arguments are passed to a function.</short>
211
<element name="arccos">
212
<short>Return inverse cosine</short>
214
<var>Arccos</var> returns the inverse cosine of its argument <var>x</var>. The
215
argument <var>x</var> should lie between -1 and 1 (borders included).
218
If the argument <var>x</var> is not in the allowed range, an
219
<var>EInvalidArgument</var> exception is raised.
227
<example file="mathex/ex1"/>
230
<element name="arcosh">
231
<short>Return inverse hyperbolic cosine</short>
233
<var>Arcosh</var> returns the inverse hyperbolic cosine of its argument <var>x</var>.
234
The argument <var>x</var> should be larger than 1.
236
The <var>arccosh</var> variant of this function is supplied for Delphi
240
If the argument <var>x</var> is not in the allowed range, an <var>EInvalidArgument</var>
251
<example file="mathex/ex3"/>
254
<element name="arcsin">
255
<short>Return inverse sine</short>
257
<var>Arcsin</var> returns the inverse sine of its argument <var>x</var>. The
258
argument <var>x</var> should lie between -1 and 1.
261
If the argument <var>x</var> is not in the allowed range, an <var>EInvalidArgument</var>
270
<example file="mathex/ex2"/>
274
<element name="arctan2">
275
<short>Return arctangent of (y/x)</short>
277
<var>arctan2</var> calculates <var>arctan(y/x)</var>, and returns an angle in the
278
correct quadrant. The returned angle will be in the range $-\pi$ to
280
The values of <var>x</var> and <var>y</var> must be between -2\^{}64 and 2\^{}64,
281
moreover <var>x</var> should be different from zero.
283
On Intel systems this function is implemented with the native intel
284
<var>fpatan</var> instruction.
287
If <var>x</var> is zero, an overflow error will occur.
295
<example file="mathex/ex6"/>
298
<element name="arsinh">
299
<short>Return inverse hyperbolic sine</short>
301
<var>arsinh</var> returns the inverse hyperbolic sine of its argument <var>x</var>.
303
The <var>arscsinh</var> variant of this function is supplied for Delphi
315
<example file="mathex/ex4"/>
319
<element name="artanh">
320
<short>Return inverse hyperbolic tangent</short>
322
<var>artanh</var> returns the inverse hyperbolic tangent of its argument <var>x</var>,
323
where <var>x</var> should lie in the interval [-1,1], borders included.
325
The <var>arctanh</var> variant of this function is supplied for Delphi compatibility.
328
In case <var>x</var> is not in the interval [-1,1], an <var>EInvalidArgument</var>
337
<example file="mathex/ex5"/>
341
<element name="ceil">
342
<short>Return the lowest integer number greater than or equal to argument</short>
344
<var>Ceil</var> returns the lowest integer number greater than or equal to <var>x</var>.
345
The absolute value of <var>x</var> should be less than <var>maxint</var>.
348
If the asolute value of <var>x</var> is larger than maxint, an overflow error will
354
<example file="mathex/ex7"/>
357
<element name="cosh">
358
<short>Return hyperbolic cosine</short>
360
<var>Cosh</var> returns the hyperbolic cosine of it's argument {x}.
370
<example file="mathex/ex8"/>
374
<element name="cotan">
375
<short>Return cotangent</short>
377
<var>Cotan</var> returns the cotangent of it's argument <var>x</var>. <var>x</var> should
378
be different from zero.
381
If <var>x</var> is zero then a overflow error will occur.
386
<example file="mathex/ex9"/>
390
<element name="cycletorad">
391
<short>Convert cycle angle to radians angle</short>
393
<var>Cycletorad</var> transforms it's argument <var>cycle</var>
394
(an angle expressed in cycles) to radians.
395
(1 cycle is $2 \pi$ radians).
401
<link id="degtograd"/>
402
<link id="degtorad"/>
403
<link id="radtodeg"/>,
404
<link id="radtograd"/>
405
<link id="radtocycle"/>
407
<example file="mathex/ex10"/>
411
<element name="degtograd">
412
<short>Convert degree angle to grads angle</short>
414
<var>Degtograd</var> transforms it's argument <var>deg</var> (an angle in degrees)
417
(90 degrees is 100 grad.)
423
<link id="cycletorad"/>
424
<link id="degtorad"/>
425
<link id="radtodeg"/>,
426
<link id="radtograd"/>
427
<link id="radtocycle"/>
429
<example file="mathex/ex11"/>
433
<element name="degtorad">
434
<short>Convert degree angle to radians angle.</short>
436
<var>Degtorad</var> converts it's argument <var>deg</var> (an angle in degrees) to
439
(pi radians is 180 degrees)
445
<link id="cycletorad"/>
446
<link id="degtograd"/>
447
<link id="radtodeg"/>,
448
<link id="radtograd"/>
449
<link id="radtocycle"/>
451
<example file="mathex/ex12"/>
455
<element name="floor">
456
<short>Return the largest integer smaller than or equal to argument</short>
458
<var>Floor</var> returns the largest integer smaller than or equal to <var>x</var>.
459
The absolute value of <var>x</var> should be less than <var>maxint</var>.
462
If <var>x</var> is larger than <var>maxint</var>, an overflow will occur.
467
<example file="mathex/ex13"/>
471
<element name="frexp">
472
<short>Return mantissa and exponent.</short>
474
<var>Frexp</var> returns the mantissa and exponent of it's argument
475
<var>x</var> in <var>mantissa</var> and <var>exponent</var>.
482
<example file="mathex/ex14"/>
486
<element name="gradtodeg">
487
<short>Convert grads angle to degrees angle</short>
489
<var>Gradtodeg</var> converts its argument <var>grad</var> (an angle in grads)
492
(100 grad is 90 degrees)
498
<link id="cycletorad"/>
499
<link id="degtograd"/>
500
<link id="radtodeg"/>,
501
<link id="radtograd"/>
502
<link id="radtocycle"/>
503
<link id="gradtorad"/>
505
<example file="mathex/ex15"/>
509
<element name="gradtorad">
510
<short>Convert grads angle to radians angle</short>
512
<var>Gradtorad</var> converts its argument <var>grad</var> (an angle in grads)
515
(200 grad is pi degrees).
521
<link id="cycletorad"/>
522
<link id="degtograd"/>
523
<link id="radtodeg"/>,
524
<link id="radtograd"/>
525
<link id="radtocycle"/>
526
<link id="gradtodeg"/>
528
<example file="mathex/ex16"/>
532
<element name="hypot">
533
<short>Return hypotenuse of triangle</short>
535
<var>Hypot</var> returns the hypotenuse of the triangle where the sides
536
adjacent to the square angle have lengths <var>x</var> and <var>y</var>.
538
The function uses Pythagoras' rule for this.
545
<example file="mathex/ex17"/>
549
<element name="intpower">
550
<short>Return integer power.</short>
552
<var>Intpower</var> returns <var>base</var> to the power <var>exponent</var>,
553
where exponent is an integer value.
556
If <var>base</var> is zero and the exponent is negative, then an
557
overflow error will occur.
562
<example file="mathex/ex18"/>
566
<element name="ldexp">
567
<short>Return (2 to the power p) times x</short>
569
<var>Ldexp</var> returns (2 to the power <var>p</var>) times <var>x</var>.
580
<example file="mathex/ex19"/>
584
<element name="lnxp1">
585
<short>Return natural logarithm of 1+X</short>
587
<var>Lnxp1</var> returns the natural logarithm of <var>1+X</var>. The result
588
is more precise for small values of <var>x</var>. <var>x</var> should be larger
592
If $x\leq -1$ then an <var>EInvalidArgument</var> exception will be raised.
600
<example file="mathex/ex20"/>
603
<element name="log10">
604
<short>Return 10-Based logarithm.</short>
606
<var>Log10</var> returns the 10-base logarithm of <var>X</var>.
609
If <var>x</var> is less than or equal to 0 an 'invalid fpu operation' error
618
<example file="mathex/ex21"/>
622
<element name="log2">
623
<short>Return 2-based logarithm</short>
625
<var>Log2</var> returns the 2-base logarithm of <var>X</var>.
628
If <var>x</var> is less than or equal to 0 an 'invalid fpu operation' error
637
<example file="mathex/ex22"/>
641
<element name="logn">
642
<short>Return N-based logarithm.</short>
644
<var>Logn</var> returns the n-base logarithm of <var>X</var>.
647
If <var>x</var> is less than or equal to 0 an 'invalid fpu operation' error
656
<example file="mathex/ex23"/>
660
<short>Return largest of 2 values</short>
662
<var>Max</var> returns the maximum of <var>Int1</var> and <var>Int2</var>.
669
<link id="maxIntValue"/>
670
<link id="maxvalue"/>
672
<example file="mathex/ex24"/>
675
<element name="maxIntValue">
676
<short>Return largest element in integer array</short>
679
<var>MaxIntValue</var> returns the largest integer out of the <var>Data</var>
683
This function is provided for Delphi compatibility, use the <link id="maxvalue"/>
691
<link id="maxvalue"/>
692
<link id="minvalue"/>
693
<link id="minIntValue"/>
695
<example file="mathex/ex25"/>
699
<element name="maxvalue">
700
<short>Return largest value in array</short>
703
<var>Maxvalue</var> returns the largest value in the <var>data</var>
704
array with integer or float values. The return value has
705
the same type as the elements of the array.
708
The third and fourth forms accept a pointer to an array of <var>N</var>
709
integer or float values.
716
<link id="maxIntValue"/>
717
<link id="minvalue"/>
718
<link id="minIntValue"/>
720
<example file="mathex/ex26"/>
723
<element name="mean">
724
<short>Return mean value of array</short>
726
<var>Mean</var> returns the average value of <var>data</var>.
728
The second form accepts a pointer to an array of <var>N</var> values.
734
<link id="meanandstddev"/>
735
<link id="momentskewkurtosis"/>
738
<example file="mathex/ex27"/>
741
<element name="meanandstddev">
742
<short>Return mean and standard deviation of array</short>
744
<var>meanandstddev</var> calculates the mean and standard deviation of <var>data</var>
745
and returns the result in <var>mean</var> and <var>stddev</var>, respectively.
746
Stddev is zero if there is only one value.
748
The second form accepts a pointer to an array of <var>N</var> values.
756
<link id="sumofsquares"/>
757
<link id="momentskewkurtosis"/>
759
<example file="mathex/ex28"/>
764
<short>Return smallest of two values.</short>
766
<var>min</var> returns the smallest value of <var>Int1</var> and <var>Int2</var>;
774
<example file="mathex/ex29"/>
777
<element name="minIntValue">
778
<short>Return smallest value in integer array</short>
781
<var>MinIntvalue</var> returns the smallest value in the <var>Data</var> array.
784
This function is provided for Delphi compatibility, use <var>minvalue</var>
792
<link id="minvalue"/>
793
<link id="maxIntValue"/>
794
<link id="maxvalue"/>
796
<example file="mathex/ex30"/>
800
<element name="minvalue">
801
<short>Return smallest value in array</short>
804
<var>Minvalue</var> returns the smallest value in the <var>data</var>
805
array with integer or float values. The return value has
806
the same type as the elements of the array.
809
The third and fourth forms accept a pointer to an array of <var>N</var>
810
integer or float values.
817
<link id="maxIntValue"/>
818
<link id="maxvalue"/>
819
<link id="minIntValue"/>
821
<example file="mathex/ex31"/>
825
<element name="momentskewkurtosis">
826
<short>Return 4 first moments of distribution</short>
828
<var>momentskewkurtosis</var> calculates the 4 first moments of the distribution
829
of valuesin <var>data</var> and returns them in <var>m1</var>,<var>m2</var>,<var>m3</var> and
830
<var>m4</var>, as well as the <var>skew</var> and <var>kurtosis</var>.
837
<link id="meanandstddev"/>
839
<example file="mathex/ex32"/>
842
<element name="norm">
843
<short>Return Euclidian norm</short>
846
<var>Norm</var> calculates the Euclidian norm of the array of data.
847
This equals <var>sqrt(sumofsquares(data))</var>.
850
The second form accepts a pointer to an array of <var>N</var> values.
857
<link id="sumofsquares"/>
859
<example file="mathex/ex33"/>
863
<element name="popnstddev">
864
<short>Return population variance</short>
867
<var>Popnstddev</var> returns the square root of the population variance of
868
the values in the <var>Data</var> array. It returns zero if there is only one value.
871
The second form of this function accepts a pointer to an array of <var>N</var>
879
<link id="popnvariance"/>
881
<link id="meanandstddev"/>
883
<link id="momentskewkurtosis"/>
885
<example file="mathex/ex35"/>
889
<element name="popnvariance">
890
<short>Return population variance</short>
893
<var>Popnvariance</var> returns the square root of the population variance of
894
the values in the <var>Data</var> array. It returns zero if there is only one value.
897
The second form of this function accepts a pointer to an array of <var>N</var>
905
<link id="popnstddev"/>
907
<link id="meanandstddev"/>
909
<link id="momentskewkurtosis"/>
911
<example file="mathex/ex36"/>
915
<element name="power">
916
<short>Return real power.</short>
918
<var>power</var> raises <var>base</var> to the power <var>power</var>. This is equivalent
919
to <var>exp(power*ln(base))</var>. Therefore <var>base</var> should be non-negative.
925
<link id="intpower"/>
927
<example file="mathex/ex34"/>
931
<element name="radtocycle">
932
<short>Convert radians angle to cycle angle</short>
935
<var>Radtocycle</var> converts its argument <var>rad</var> (an angle expressed in
936
radians) to an angle in cycles.
939
(1 cycle equals 2 <var>pi</var> radians)
946
<link id="degtograd"/>
947
<link id="degtorad"/>
948
<link id="radtodeg"/>,
949
<link id="radtograd"/>
950
<link id="cycletorad"/>
952
<example file="mathex/ex37"/>
956
<element name="radtodeg">
957
<short>Convert radians angle to degrees angle</short>
959
<var>Radtodeg</var> converts its argument <var>rad</var> (an angle expressed in
960
radians) to an angle in degrees.
962
(180 degrees equals pi radians)
968
<link id="degtograd"/>
969
<link id="degtorad"/>
970
<link id="radtocycle"/>,
971
<link id="radtograd"/>
972
<link id="cycletorad"/>
974
<example file="mathex/ex38"/>
978
<element name="radtograd">
979
<short>Convert radians angle to grads angle</short>
982
<var>Radtodeg</var> converts its argument <var>rad</var> (an angle expressed in
983
radians) to an angle in grads.
986
(200 grads equals pi radians)
993
<link id="degtograd"/>
994
<link id="degtorad"/>
995
<link id="radtocycle"/>,
996
<link id="radtodeg"/>
997
<link id="cycletorad"/>
999
<example file="mathex/ex39"/>
1003
<element name="randg">
1004
<short>Return gaussian distributed random number.</short>
1006
<var>randg</var> returns a random number which - when produced in large
1007
quantities - has a Gaussian distribution with mean <var>mean</var> and
1008
standarddeviation <var>stddev</var>.
1016
<link id="meanandstddev"/>
1018
<example file="mathex/ex40"/>
1022
<element name="sincos">
1023
<short>Return sine and cosine of argument</short>
1026
<var>Sincos</var> calculates the sine and cosine of the angle <var>theta</var>,
1027
and returns the result in <var>sinus</var> and <var>cosinus</var>.
1030
On Intel hardware, This calculation will be faster than making 2 calls
1031
to calculate the sine and cosine separately.
1039
<link id="arccos"/>.
1041
<example file="mathex/ex41"/>
1045
<element name="sinh">
1046
<short>Return hyperbolic sine</short>
1048
<var>Sinh</var> returns the hyperbolic sine of its argument <var>x</var>.
1058
<example file="mathex/ex42"/>
1062
<element name="stddev">
1063
<short>Return standard deviation of data</short>
1066
<var>Stddev</var> returns the standard deviation of the values in <var>Data</var>.
1067
It returns zero if there is only one value.
1070
The second form of the function accepts a pointer to an array of <var>N</var>
1079
<link id="meanandstddev"/>
1080
<link id="variance"/>
1081
<link id="totalvariance"/>
1083
<example file="mathex/ex43"/>
1087
<element name="sum">
1088
<short>Return sum of values</short>
1091
<var>Sum</var> returns the sum of the values in the <var>data</var> array.
1094
The second form of the function accepts a pointer to an array of <var>N</var>
1102
<link id="sumofsquares"/>
1103
<link id="sumsandsquares"/>
1104
<link id="totalvariance"/>
1105
<link id="variance"/>
1107
<example file="mathex/ex44"/>
1111
<element name="sumofsquares">
1112
<short>Return sum of squares of values</short>
1115
<var>Sumofsquares</var> returns the sum of the squares of the values in the <var>data</var>
1119
The second form of the function accepts a pointer to an array of <var>N</var>
1128
<link id="sumsandsquares"/>
1129
<link id="totalvariance"/>
1130
<link id="variance"/>
1132
<example file="mathex/ex45"/>
1136
<element name="sumsandsquares">
1137
<short>Return sum and sum of squares of values.</short>
1140
<var>sumsandsquares</var> calculates the sum of the values and the sum of
1141
the squares of the values in the <var>data</var> array and returns the
1142
results in <var>sum</var> and <var>sumofsquares</var>.
1145
The second form of the function accepts a pointer to an array of <var>N</var>
1154
<link id="sumofsquares"/>
1155
<link id="totalvariance"/>
1156
<link id="variance"/>
1158
<example file="mathex/ex46"/>
1162
<element name="tan">
1163
<short>Return tangent</short>
1165
<var>Tan</var> returns the tangent of <var>x</var>.
1168
If <var>x</var> (normalized) is pi/2 or 3pi/2 then an overflow will occur.
1176
<example file="mathex/ex47"/>
1180
<element name="tanh">
1181
<short>Return hyperbolic tangent</short>
1183
<var>Tanh</var> returns the hyperbolic tangent of <var>x</var>.
1193
<example file="mathex/ex48"/>
1197
<element name="totalvariance">
1198
<short>Return total varians of values</short>
1201
<var>TotalVariance</var> returns the total variance of the values in the
1202
<var>data</var> array. It returns zero if there is only one value.
1205
The second form of the function accepts a pointer to an array of <var>N</var>
1213
<link id="variance"/>
1217
<example file="mathex/ex49"/>
1221
<element name="variance">
1222
<short>Return variance of values</short>
1225
<var>Variance</var> returns the variance of the values in the
1226
<var>data</var> array. It returns zero if there is only one value.
1229
The second form of the function accepts a pointer to an array of <var>N</var>
1237
<link id="totalvariance"/>
1241
<example file="mathex/ex50"/>
1244
<!-- unresolved type reference Visibility: default -->
1245
<element name="sysutils">
1246
<short>Used for exception definitions.</short>
1249
<!-- constant Visibility: default -->
1250
<element name="MinExtended">
1251
<short>Minimum value (closest to zero) of extended type</short>
1254
<!-- constant Visibility: default -->
1255
<element name="MaxExtended">
1256
<short>Maximum value of extended type</short>
1259
<!-- constant Visibility: default -->
1260
<element name="MinFloat">
1261
<short>Minimum value (closest to zero) of float type</short>
1264
<!-- constant Visibility: default -->
1265
<element name="MaxFloat">
1266
<short>Maximum value of float type</short>
1269
<!-- pointer type Visibility: default -->
1270
<element name="PInteger">
1271
<short>Pointer to integer type</short>
1274
<!-- range type Visibility: default -->
1275
<element name="TValueRelationship">
1276
<short>Type to describe relational order between values</short>
1279
<!-- constant Visibility: default -->
1280
<element name="EqualsValue">
1281
<short>Values are the same</short>
1284
<!-- constant Visibility: default -->
1285
<element name="LessThanValue">
1286
<short>First value is less than second value</short>
1289
<!-- constant Visibility: default -->
1290
<element name="GreaterThanValue">
1291
<short>First values is greater than second value</short>
1294
<!-- constant Visibility: default -->
1295
<element name="NaN">
1296
<short>Value is Not a Number</short>
1299
<!-- constant Visibility: default -->
1300
<element name="Infinity">
1301
<short>Value is infinity</short>
1304
<!-- function Visibility: default -->
1305
<element name="InRange">
1306
<short>Check whether value is in range.</short>
1308
<var>InRange</var> returns <var>True</var> if <var>AValue</var> is in the
1309
range <var>AMin</var>..<var>AMax</var>. It returns <var>False</var> if
1310
<var>Value</var> lies outside the specified range.
1313
<link id="EnsureRange"/>
1317
<!-- function Visibility: default -->
1318
<element name="EnsureRange">
1319
<short>Change value to it falls in specified range.</short>
1321
<var>EnsureRange</var> returns <var>Value</var> if <var>AValue</var> is in
1322
the range <var>AMin</var>..<var>AMax</var>. It returns <var>AMin</var> if
1323
the value is less than <var>AMin</var>, or <var>AMax</var> if the value is
1324
larger than <var>AMax</var>.
1327
<link id="InRange"/>
1331
<!-- procedure Visibility: default -->
1332
<element name="DivMod">
1333
<short>Return DIV and MOD of arguments </short>
1335
<var>DivMod</var> returns <var>Dividend</var> DIV <var>Divisor</var> in
1336
<var>Result</var>, and <var>Dividend</var> MOD <var>Divisor</var> in
1337
<var>Remainder</var>
1341
<!-- range type Visibility: default -->
1342
<element name="TValueSign">
1343
<short>Type indicating sign of a valuea</short>
1346
<!-- constant Visibility: default -->
1347
<element name="NegativeValue">
1348
<short>Value is negative</short>
1351
<!-- constant Visibility: default -->
1352
<element name="ZeroValue">
1353
<short>Value is zero</short>
1356
<!-- constant Visibility: default -->
1357
<element name="PositiveValue">
1358
<short>Value is positive</short>
1361
<!-- function Visibility: default -->
1362
<element name="Sign">
1363
<short>Return sign of argument</short>
1365
<var>Sign</var> returns the sign of it's argument, which can be an Integer,
1366
64 bit integer, or a double. The returned value is an integer which is -1, 0
1367
or 1, and can be used to do further calculations with.
1371
<!-- function Visibility: default -->
1372
<element name="IsZero">
1373
<short>Check whether value is zero</short>
1376
<var>IsZero</var> checks whether the float value <var>A</var> is zero, up to a
1377
precision of <var>Epsilon</var>. It returns <var>True</var> if Abs(<var>A</var>) is
1378
less than <var>Epsilon</var>.
1381
The default value for <var>Epsilon</var> is dependent on the type of the
1382
arguments, but is <link id="MinFloat"/> for the float type.
1387
<link id="IsInfinite"/>
1388
<link id="SameValue"/>
1392
<!-- function Visibility: default -->
1393
<element name="IsNan">
1394
<short>Check whether value is Not a Number</short>
1396
<var>IsNan</var> returns <var>True</var> if the double <var>d</var>
1397
contains Not A Number (a value which cannot be represented correctly
1402
<link id="IsInfinite"/>
1406
<!-- function Visibility: default -->
1407
<element name="IsInfinite">
1408
<short>Check whether value is infinite</short>
1410
<var>IsInfinite</var> returns <var>True</var> if the double <var>d</var>
1411
contains the infinite value.
1415
<link id="IsInfinite"/>
1419
<!-- function Visibility: default -->
1420
<element name="SameValue">
1421
<short>Check whether 2 float values are the same</short>
1424
<var>SameValue</var> returns <var>True</var> if the floating-point values
1425
<var>A</var> and <var>B</var> are the same, i.e. whether the absolute value
1426
of their their difference is smaller than <var>Epsilon</var>. If their
1427
difference is larger, then <var>False</var> is returned.
1430
The default value for <var>Epsilon</var> is dependent on the type of the
1431
arguments, but is <link id="MinFloat"/> for the float type.
1435
<link id="MinFloat"/>
1440
<!-- function Visibility: default -->
1441
<element name="arccosh">
1442
<short>Return inverse hyperbolic cosine</short>
1445
<var>arccosh</var> returns the inverse hyperbolic cosine of it's argument
1449
This function is an alias for <link id="arcosh"/>, provided for Delphi
1458
<!-- function Visibility: default -->
1459
<element name="arcsinh">
1460
<short>Return inverse hyperbolic sine</short>
1463
<var>arcsinh</var> returns the inverse hyperbolic sine of it's argument
1467
This function is an alias for <link id="arsinh"/>, provided for Delphi
1476
<!-- function Visibility: default -->
1477
<element name="arctanh">
1478
<short>Return inverse hyperbolic tangent</short>
1481
<var>arcsinh</var> returns the inverse hyperbolic tangent of it's argument
1485
This function is an alias for <link id="artanh"/>, provided for Delphi
1494
<!-- enumeration type Visibility: default -->
1495
<element name="TFPURoundingMode">
1496
<short>Type describing the rounding mode for the Floating Point processor.</short>
1499
<!-- enumeration value Visibility: default -->
1500
<element name="TFPURoundingMode.rmNearest">
1501
<short>Round to nearest integer value</short>
1504
<!-- enumeration value Visibility: default -->
1505
<element name="TFPURoundingMode.rmDown">
1506
<short>Round to biggest integer smaller than value.</short>
1509
<!-- enumeration value Visibility: default -->
1510
<element name="TFPURoundingMode.rmUp">
1511
<short>Round to smallest integer larger than value.</short>
1514
<!-- enumeration value Visibility: default -->
1515
<element name="TFPURoundingMode.rmTruncate">
1516
<short>Cut off fractional part.</short>
1519
<!-- enumeration type Visibility: default -->
1520
<element name="TFPUPrecisionMode">
1521
<short>Type describing the default precision for the Floating Point processor.</short>
1524
<!-- enumeration value Visibility: default -->
1525
<element name="TFPUPrecisionMode.pmSingle">
1526
<short>Single-type precision</short>
1529
<!-- enumeration value Visibility: default -->
1530
<element name="TFPUPrecisionMode.pmReserved">
1534
<!-- enumeration value Visibility: default -->
1535
<element name="TFPUPrecisionMode.pmDouble">
1536
<short>Double-type precision</short>
1539
<!-- enumeration value Visibility: default -->
1540
<element name="TFPUPrecisionMode.pmExtended">
1541
<short>Extended-type precision</short>
1544
<!-- enumeration type Visibility: default -->
1545
<element name="TFPUException">
1546
<short>Type describing Floating Point processor exceptions.</short>
1549
<!-- enumeration value Visibility: default -->
1550
<element name="TFPUException.exInvalidOp">
1551
<short>Invalid operation error</short>
1554
<!-- enumeration value Visibility: default -->
1555
<element name="TFPUException.exDenormalized">
1559
<!-- enumeration value Visibility: default -->
1560
<element name="TFPUException.exZeroDivide">
1561
<short>Division by zero error.</short>
1564
<!-- enumeration value Visibility: default -->
1565
<element name="TFPUException.exOverflow">
1566
<short>Float overflow error</short>
1569
<!-- enumeration value Visibility: default -->
1570
<element name="TFPUException.exUnderflow">
1571
<short>Float underflow error</short>
1574
<!-- enumeration value Visibility: default -->
1575
<element name="TFPUException.exPrecision">
1576
<short>Precision error</short>
1579
<!-- set type Visibility: default -->
1580
<element name="TFPUExceptionMask">
1581
<short>Type to set the Floating Point Unit exception mask.</short>
1584
<!-- function Visibility: default -->
1585
<element name="GetRoundMode">
1586
<short>Return the Floating Point Unit rounding mode.</short>
1591
<!-- function Visibility: default -->
1592
<element name="SetRoundMode">
1593
<short>Set the Floating Point Unit rounding mode.</short>
1598
<!-- function Visibility: default -->
1599
<element name="GetPrecisionMode">
1600
<short>Return the Floating Point Unit precision mode.</short>
1605
<!-- function Visibility: default -->
1606
<element name="SetPrecisionMode">
1607
<short>Set the Floating Point Unit precision mode.</short>
1612
<!-- function Visibility: default -->
1613
<element name="GetExceptionMask">
1614
<short>Get the Floating Point Unit exception mask.</short>
1619
<!-- function Visibility: default -->
1620
<element name="SetExceptionMask">
1621
<short>Set the Floating Point Unit exception mask.</short>
1626
<!-- procedure Visibility: default -->
1627
<element name="ClearExceptions">
1628
<short>Clear Floating Point Unit exceptions</short>
1633
<element name="GetSSECSR">
1634
<short>Get MXCSR control word (Intel only)</short>
1636
<var>GetSSECSR</var> can be used to get the SSE/SSE2 control DWord.
1637
It is equivalent to the <var>LDMXCSR</var> assembler instruction, and
1638
returns the control dword.
1642
<element name="ifthen">
1643
<short>Return one of two values, depending on a boolean condition</short>
1646
<var>ifthen</var> returns <var>iftrue</var> if <var>val</var> is
1647
<var>True</var>, and <var>False</var> if <var>val</var> is <var>False</var>.
1650
This function can be used in expressions.
1655
<element name="SetSSECSR">
1656
<short>Set MXCSR control word (Intel only)</short>
1658
<var>SetSSECSR</var> can be used to set the SSE/SSE2 control DWord.
1659
It is equivalent to the <var>STMXCSR</var> assembler instruction, and stores
1660
<var>w</var> in the control dword.
1665
<!-- unresolved type reference Visibility: default -->
1666
<element name="sysutils">
1667
<short>Exception support</short>
1670
<!-- function Visibility: default -->
1671
<element name="operator **">
1672
<short>Exponent operator</short>
1674
<var>**</var> raises <var>base</var> to the power <var>expt</var>. Both numbers can be floats or 64-bit integers.
1677
Overflow exceptions can occur.
1683
<!-- function Visibility: default -->
1684
<element name="sumInt">
1685
<short>Return the sum of an array of integers</short>
1687
<var>SumInt</var> returns the sum of the <var>N</var> integers in the <var>Data</var>
1688
array, where this can be an open array or a pointer to an array.
1691
An overflow may occur.
1698
</fpdoc-descriptions>