math.tex 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004
  1. %
  2. % $Id$
  3. % This file is part of the FPC documentation.
  4. % Copyright (C) 2000 by Florian Klaempfl
  5. %
  6. % The FPC documentation is free text; you can redistribute it and/or
  7. % modify it under the terms of the GNU Library General Public License as
  8. % published by the Free Software Foundation; either version 2 of the
  9. % License, or (at your option) any later version.
  10. %
  11. % The FPC Documentation is distributed in the hope that it will be useful,
  12. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. % Library General Public License for more details.
  15. %
  16. % You should have received a copy of the GNU Library General Public
  17. % License along with the FPC documentation; see the file COPYING.LIB. If not,
  18. % write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. % Boston, MA 02111-1307, USA.
  20. %
  21. \chapter{The MATH unit}
  22. \FPCexampledir{mathex}
  23. This chapter describes the \file{math} unit. The \var{math} unit
  24. was initially written by Florian Klaempfl. It provides mathematical
  25. functions which aren't covered by the system unit.
  26. This chapter starts out with a definition of all types and constants
  27. that are defined, followed by a complete explanation of each function.
  28. The following things must be taken into account when using this unit:
  29. \begin{enumerate}
  30. \item This unit is compiled in Object Pascal mode so all
  31. \var{integers} are 32 bit.
  32. \item Some overloaded functions exist for data arrays of integers and
  33. floats. When using the address operator (\var{@}) to pass an array of
  34. data to such a function, make sure the address is typecasted to the
  35. right type, or turn on the 'typed address operator' feature. failing to
  36. do so, will cause the compiler not be able to decide which function you
  37. want to call.
  38. \end{enumerate}
  39. \section{Constants and types}
  40. The following types are defined in the \file{math} unit:
  41. \begin{verbatim}
  42. Type
  43. Float = Extended;
  44. PFloat = ^FLoat
  45. \end{verbatim}
  46. All calculations are done with the Float type. This allows to
  47. recompile the unit with a different float type to obtain a
  48. desired precision. The pointer type is used in functions that accept
  49. an array of values of arbitrary length.
  50. \begin{verbatim}
  51. Type
  52. TPaymentTime = (PTEndOfPeriod,PTStartOfPeriod);
  53. \end{verbatim}
  54. \var{TPaymentTime} is used in the financial calculations.
  55. \begin{verbatim}
  56. Type
  57. EInvalidArgument = Class(EMathError);
  58. \end{verbatim}
  59. The \var{EInvalidArgument} exception is used to report invalid arguments.
  60. \section{Function list by category}
  61. What follows is a listing of the available functions, grouped by category.
  62. Foe each function there is a reference to the page where you can find the
  63. function.
  64. \subsection{Min/max determination}
  65. Functions to determine the minimum or maximum of numbers:
  66. \begin{funclist}
  67. \funcref{max}{Maximum of 2 values}
  68. \funcref{maxIntValue}{Maximum of an array of integer values}
  69. \funcref{maxvalue}{Maximum of an array of values}
  70. \funcref{min}{Minimum of 2 values}
  71. \funcref{minIntValue}{Minimum of an array of integer values}
  72. \funcref{minvalue}{Minimum of an array of values}
  73. \end{funclist}
  74. \subsection{Angle conversion}
  75. \begin{funclist}
  76. \funcref{cycletorad}{convert cycles to radians}
  77. \funcref{degtograd}{convert degrees to grads}
  78. \funcref{degtorad}{convert degrees to radians}
  79. \funcref{gradtodeg}{convert grads to degrees}
  80. \funcref{gradtorad}{convert grads to radians}
  81. \funcref{radtocycle}{convert radians to cycles}
  82. \funcref{radtodeg}{convert radians to degrees}
  83. \funcref{radtograd}{convert radians to grads}
  84. \end{funclist}
  85. \subsection{Trigoniometric functions}
  86. \begin{funclist}
  87. \funcref{arccos}{calculate reverse cosine}
  88. \funcref{arcsin}{calculate reverse sine}
  89. \funcref{arctan2}{calculate reverse tangent}
  90. \funcref{cotan}{calculate cotangent}
  91. \procref{sincos}{calculate sine and cosine}
  92. \funcref{tan}{calculate tangent}
  93. \end{funclist}
  94. \subsection{Hyperbolic functions}
  95. \begin{funclist}
  96. \funcref{arcosh}{caculate reverse hyperbolic cosine}
  97. \funcref{arsinh}{caculate reverse hyperbolic sine}
  98. \funcref{artanh}{caculate reverse hyperbolic tangent}
  99. \funcref{cosh}{calculate hyperbolic cosine}
  100. \funcref{sinh}{calculate hyperbolic sine}
  101. \funcref{tanh}{calculate hyperbolic tangent}
  102. \end{funclist}
  103. \subsection{Exponential and logarithmic functions}
  104. \begin{funclist}
  105. \funcref{intpower}{Raise float to integer power}
  106. \funcref{ldexp}{Calculate $2^p x$}
  107. \funcref{lnxp1}{calculate \var{log(x+1)}}
  108. \funcref{log10}{calculate 10-base log}
  109. \funcref{log2}{calculate 2-base log}
  110. \funcref{logn}{calculate N-base log}
  111. \funcref{power}{raise float to arbitrary power}
  112. \end{funclist}
  113. \subsection{Number converting}
  114. \begin{funclist}
  115. \funcref{ceil}{Round to infinity}
  116. \funcref{floor}{Round to minus infinity}
  117. \procref{frexp}{Return mantissa and exponent}
  118. \end{funclist}
  119. \subsection{Statistical functions}
  120. \begin{funclist}
  121. \funcref{mean}{Mean of values}
  122. \procref{meanandstddev}{Mean and standard deviation of values}
  123. \procref{momentskewkurtosis}{Moments, skew and kurtosis}
  124. \funcref{popnstddev}{Population standarddeviation }
  125. \funcref{popnvariance}{Population variance}
  126. \funcref{randg}{Gaussian distributed randum value}
  127. \funcref{stddev}{Standard deviation}
  128. \funcref{sum}{Sum of values}
  129. \funcref{sumofsquares}{Sum of squared values}
  130. \procref{sumsandsquares}{Sum of values and squared values}
  131. \funcref{totalvariance}{Total variance of values}
  132. \funcref{variance}{variance of values}
  133. \end{funclist}
  134. \subsection{Geometrical functions}
  135. \begin{funclist}
  136. \funcref{hypot}{Hypotenuse of triangle}
  137. \funcref{norm}{Euclidian norm}
  138. \end{funclist}
  139. \section{Functions and Procedures}
  140. \begin{function}{arccos}
  141. \Declaration
  142. Function arccos(x : float) : float;
  143. \Description
  144. \var{Arccos} returns the inverse cosine of its argument \var{x}. The
  145. argument \var{x} should lie between -1 and 1 (borders included).
  146. \Errors
  147. If the argument \var{x} is not in the allowed range, an
  148. \var{EInvalidArgument} exception is raised.
  149. \SeeAlso
  150. \seef{arcsin}, \seef{arcosh}, \seef{arsinh}, \seef{artanh}
  151. \end{function}
  152. \FPCexample{ex1}
  153. \begin{function}{arcosh}
  154. \Declaration
  155. Function arcosh(x : float) : float;
  156. Function arccosh(x : float) : float;
  157. \Description
  158. \var{Arcosh} returns the inverse hyperbolic cosine of its argument \var{x}.
  159. The argument \var{x} should be larger than 1.
  160. The \var{arccosh} variant of this function is supplied for \delphi
  161. compatibility.
  162. \Errors
  163. If the argument \var{x} is not in the allowed range, an \var{EInvalidArgument}
  164. exception is raised.
  165. \SeeAlso
  166. \seef{cosh}, \seef{sinh}, \seef{arcsin}, \seef{arsinh}, \seef{artanh},
  167. \seef{tanh}
  168. \end{function}
  169. \FPCexample{ex3}
  170. \begin{function}{arcsin}
  171. \Declaration
  172. Function arcsin(x : float) : float;
  173. \Description
  174. \var{Arcsin} returns the inverse sine of its argument \var{x}. The
  175. argument \var{x} should lie between -1 and 1.
  176. \Errors
  177. If the argument \var{x} is not in the allowed range, an \var{EInvalidArgument}
  178. exception is raised.
  179. \SeeAlso
  180. \seef{arccos}, \seef{arcosh}, \seef{arsinh}, \seef{artanh}
  181. \end{function}
  182. \FPCexample{ex2}
  183. \begin{function}{arctan2}
  184. \Declaration
  185. Function arctan2(x,y : float) : float;
  186. \Description
  187. \var{arctan2} calculates \var{arctan(y/x)}, and returns an angle in the
  188. correct quadrant. The returned angle will be in the range $-\pi$ to
  189. $\pi$ radians.
  190. The values of \var{x} and \var{y} must be between -2\^{}64 and 2\^{}64,
  191. moreover \var{x} should be different from zero.
  192. On Intel systems this function is implemented with the native intel
  193. \var{fpatan} instruction.
  194. \Errors
  195. If \var{x} is zero, an overflow error will occur.
  196. \SeeAlso
  197. \seef{arccos}, \seef{arcosh}, \seef{arsinh}, \seef{artanh}
  198. \end{function}
  199. \FPCexample{ex6}
  200. \begin{function}{arsinh}
  201. \Declaration
  202. Function arsinh(x : float) : float;
  203. Function arcsinh(x : float) : float;
  204. \Description
  205. \var{arsinh} returns the inverse hyperbolic sine of its argument \var{x}.
  206. The \var{arscsinh} variant of this function is supplied for \delphi
  207. compatibility.
  208. \Errors
  209. None.
  210. \SeeAlso
  211. \seef{arcosh}, \seef{arccos}, \seef{arcsin}, \seef{artanh}
  212. \end{function}
  213. \FPCexample{ex4}
  214. \begin{function}{artanh}
  215. \Declaration
  216. Function artanh(x : float) : float;
  217. Function arctanh(x : float) : float;
  218. \Description
  219. \var{artanh} returns the inverse hyperbolic tangent of its argument \var{x},
  220. where \var{x} should lie in the interval [-1,1], borders included.
  221. The \var{arctanh} variant of this function is supplied for \delphi compatibility.
  222. \Errors
  223. In case \var{x} is not in the interval [-1,1], an \var{EInvalidArgument}
  224. exception is raised.
  225. \SeeAlso
  226. \seef{arcosh}, \seef{arccos}, \seef{arcsin}, \seef{artanh}
  227. \Errors
  228. \SeeAlso
  229. \end{function}
  230. \FPCexample{ex5}
  231. \begin{function}{ceil}
  232. \Declaration
  233. Function ceil(x : float) : longint;
  234. \Description
  235. \var{Ceil} returns the lowest integer number greater than or equal to \var{x}.
  236. The absolute value of \var{x} should be less than \var{maxint}.
  237. \Errors
  238. If the asolute value of \var{x} is larger than maxint, an overflow error will
  239. occur.
  240. \SeeAlso
  241. \seef{floor}
  242. \end{function}
  243. \FPCexample{ex7}
  244. \begin{function}{cosh}
  245. \Declaration
  246. Function cosh(x : float) : float;
  247. \Description
  248. \var{Cosh} returns the hyperbolic cosine of it's argument {x}.
  249. \Errors
  250. None.
  251. \SeeAlso
  252. \seef{arcosh}, \seef{sinh}, \seef{arsinh}
  253. \end{function}
  254. \FPCexample{ex8}
  255. \begin{function}{cotan}
  256. \Declaration
  257. Function cotan(x : float) : float;
  258. \Description
  259. \var{Cotan} returns the cotangent of it's argument \var{x}. \var{x} should
  260. be different from zero.
  261. \Errors
  262. If \var{x} is zero then a overflow error will occur.
  263. \SeeAlso
  264. \seef{tanh}
  265. \end{function}
  266. \FPCexample{ex9}
  267. \begin{function}{cycletorad}
  268. \Declaration
  269. Function cycletorad(cycle : float) : float;
  270. \Description
  271. \var{Cycletorad} transforms it's argument \var{cycle}
  272. (an angle expressed in cycles) to radians.
  273. (1 cycle is $2 \pi$ radians).
  274. \Errors
  275. None.
  276. \SeeAlso
  277. \seef{degtograd}, \seef{degtorad}, \seef{radtodeg},
  278. \seef{radtograd}, \seef{radtocycle}
  279. \end{function}
  280. \FPCexample{ex10}
  281. \begin{function}{degtograd}
  282. \Declaration
  283. Function degtograd(deg : float) : float;
  284. \Description
  285. \var{Degtograd} transforms it's argument \var{deg} (an angle in degrees)
  286. to grads.
  287. (90 degrees is 100 grad.)
  288. \Errors
  289. None.
  290. \SeeAlso
  291. \seef{cycletorad}, \seef{degtorad}, \seef{radtodeg},
  292. \seef{radtograd}, \seef{radtocycle}
  293. \end{function}
  294. \FPCexample{ex11}
  295. \begin{function}{degtorad}
  296. \Declaration
  297. Function degtorad(deg : float) : float;
  298. \Description
  299. \var{Degtorad} converts it's argument \var{deg} (an angle in degrees) to
  300. radians.
  301. (pi radians is 180 degrees)
  302. \Errors
  303. None.
  304. \SeeAlso
  305. \seef{cycletorad}, \seef{degtograd}, \seef{radtodeg},
  306. \seef{radtograd}, \seef{radtocycle}
  307. \end{function}
  308. \FPCexample{ex12}
  309. \begin{function}{floor}
  310. \Declaration
  311. Function floor(x : float) : longint;
  312. \Description
  313. \var{Floor} returns the largest integer smaller than or equal to \var{x}.
  314. The absolute value of \var{x} should be less than \var{maxint}.
  315. \Errors
  316. If \var{x} is larger than \var{maxint}, an overflow will occur.
  317. \SeeAlso
  318. \seef{ceil}
  319. \end{function}
  320. \FPCexample{ex13}
  321. \begin{procedure}{frexp}
  322. \Declaration
  323. Procedure frexp(x : float;var mantissa,exponent : float);
  324. \Description
  325. \var{Frexp} returns the mantissa and exponent of it's argument
  326. \var{x} in \var{mantissa} and \var{exponent}.
  327. \Errors
  328. None
  329. \SeeAlso
  330. \end{procedure}
  331. \FPCexample{ex14}
  332. \begin{function}{gradtodeg}
  333. \Declaration
  334. Function gradtodeg(grad : float) : float;
  335. \Description
  336. \var{Gradtodeg} converts its argument \var{grad} (an angle in grads)
  337. to degrees.
  338. (100 grad is 90 degrees)
  339. \Errors
  340. None.
  341. \SeeAlso
  342. \seef{cycletorad}, \seef{degtograd}, \seef{radtodeg},
  343. \seef{radtograd}, \seef{radtocycle}, \seef{gradtorad}
  344. \end{function}
  345. \FPCexample{ex15}
  346. \begin{function}{gradtorad}
  347. \Declaration
  348. Function gradtorad(grad : float) : float;
  349. \Description
  350. \var{Gradtorad} converts its argument \var{grad} (an angle in grads)
  351. to radians.
  352. (200 grad is pi degrees).
  353. \Errors
  354. None.
  355. \SeeAlso
  356. \seef{cycletorad}, \seef{degtograd}, \seef{radtodeg},
  357. \seef{radtograd}, \seef{radtocycle}, \seef{gradtodeg}
  358. \end{function}
  359. \FPCexample{ex16}
  360. \begin{function}{hypot}
  361. \Declaration
  362. Function hypot(x,y : float) : float;
  363. \Description
  364. \var{Hypot} returns the hypotenuse of the triangle where the sides
  365. adjacent to the square angle have lengths \var{x} and \var{y}.
  366. The function uses Pythagoras' rule for this.
  367. \Errors
  368. None.
  369. \SeeAlso
  370. \end{function}
  371. \FPCexample{ex17}
  372. \begin{function}{intpower}
  373. \Declaration
  374. Function intpower(base : float;exponent : longint) : float;
  375. \Description
  376. \var{Intpower} returns \var{base} to the power \var{exponent},
  377. where exponent is an integer value.
  378. \Errors
  379. If \var{base} is zero and the exponent is negative, then an
  380. overflow error will occur.
  381. \SeeAlso
  382. \seef{power}
  383. \end{function}
  384. \FPCexample{ex18}
  385. \begin{function}{ldexp}
  386. \Declaration
  387. Function ldexp(x : float;p : longint) : float;
  388. \Description
  389. \var{Ldexp} returns $2^p x$.
  390. \Errors
  391. None.
  392. \SeeAlso
  393. \seef{lnxp1}, \seef{log10},\seef{log2},\seef{logn}
  394. \end{function}
  395. \FPCexample{ex19}
  396. \begin{function}{lnxp1}
  397. \Declaration
  398. Function lnxp1(x : float) : float;
  399. \Description
  400. \var{Lnxp1} returns the natural logarithm of \var{1+X}. The result
  401. is more precise for small values of \var{x}. \var{x} should be larger
  402. than -1.
  403. \Errors
  404. If $x\leq -1$ then an \var{EInvalidArgument} exception will be raised.
  405. \SeeAlso
  406. \seef{ldexp}, \seef{log10},\seef{log2},\seef{logn}
  407. \end{function}
  408. \FPCexample{ex20}
  409. \begin{function}{log10}
  410. \Declaration
  411. Function log10(x : float) : float;
  412. \Description
  413. \var{Log10} returns the 10-base logarithm of \var{X}.
  414. \Errors
  415. If \var{x} is less than or equal to 0 an 'invalid fpu operation' error
  416. will occur.
  417. \SeeAlso
  418. \seef{ldexp}, \seef{lnxp1},\seef{log2},\seef{logn}
  419. \end{function}
  420. \FPCexample{ex21}
  421. \begin{function}{log2}
  422. \Declaration
  423. Function log2(x : float) : float;
  424. \Description
  425. \var{Log2} returns the 2-base logarithm of \var{X}.
  426. \Errors
  427. If \var{x} is less than or equal to 0 an 'invalid fpu operation' error
  428. will occur.
  429. \SeeAlso
  430. \seef{ldexp}, \seef{lnxp1},\seef{log10},\seef{logn}
  431. \end{function}
  432. \FPCexample{ex22}
  433. \begin{function}{logn}
  434. \Declaration
  435. Function logn(n,x : float) : float;
  436. \Description
  437. \var{Logn} returns the n-base logarithm of \var{X}.
  438. \Errors
  439. If \var{x} is less than or equal to 0 an 'invalid fpu operation' error
  440. will occur.
  441. \SeeAlso
  442. \seef{ldexp}, \seef{lnxp1},\seef{log10},\seef{log2}
  443. \end{function}
  444. \FPCexample{ex23}
  445. \begin{function}{max}
  446. \Declaration
  447. Function max(Int1,Int2:Cardinal):Cardinal;
  448. Function max(Int1,Int2:Integer):Integer;
  449. \Description
  450. \var{Max} returns the maximum of \var{Int1} and \var{Int2}.
  451. \Errors
  452. None.
  453. \SeeAlso
  454. \seef{min}, \seef{maxIntValue}, \seef{maxvalue}
  455. \end{function}
  456. \FPCexample{ex24}
  457. \begin{function}{maxIntValue}
  458. \Declaration
  459. function MaxIntValue(const Data: array of Integer): Integer;
  460. \Description
  461. \var{MaxIntValue} returns the largest integer out of the \var{Data}
  462. array.
  463. This function is provided for \delphi compatibility, use the \seef{maxvalue}
  464. function instead.
  465. \Errors
  466. None.
  467. \SeeAlso
  468. \seef{maxvalue}, \seef{minvalue}, \seef{minIntValue}
  469. \end{function}
  470. \FPCexample{ex25}
  471. \begin{function}{maxvalue}
  472. \Declaration
  473. Function maxvalue(const data : array of float) : float;
  474. Function maxvalue(const data : array of Integer) : Integer;
  475. Function maxvalue(const data : PFloat; Const N : Integer) : float;
  476. Function maxvalue(const data : PInteger; Const N : Integer) : Integer;
  477. \Description
  478. \var{Maxvalue} returns the largest value in the \var{data}
  479. array with integer or float values. The return value has
  480. the same type as the elements of the array.
  481. The third and fourth forms accept a pointer to an array of \var{N}
  482. integer or float values.
  483. \Errors
  484. None.
  485. \SeeAlso
  486. \seef{maxIntValue}, \seef{minvalue}, \seef{minIntValue}
  487. \end{function}
  488. \FPCexample{ex26}
  489. \begin{function}{mean}
  490. \Declaration
  491. Function mean(const data : array of float) : float;
  492. Function mean(const data : PFloat; Const N : longint) : float;
  493. \Description
  494. \var{Mean} returns the average value of \var{data}.
  495. The second form accepts a pointer to an array of \var{N} values.
  496. \Errors
  497. None.
  498. \SeeAlso
  499. \seep{meanandstddev}, \seep{momentskewkurtosis}, \seef{sum}
  500. \end{function}
  501. \FPCexample{ex27}
  502. \begin{procedure}{meanandstddev}
  503. \Declaration
  504. Procedure meanandstddev(const data : array of float;
  505. var mean,stddev : float);
  506. procedure meanandstddev(const data : PFloat;
  507. Const N : Longint;var mean,stddev : float);
  508. \Description
  509. \var{meanandstddev} calculates the mean and standard deviation of \var{data}
  510. and returns the result in \var{mean} and \var{stddev}, respectively.
  511. Stddev is zero if there is only one value.
  512. The second form accepts a pointer to an array of \var{N} values.
  513. \Errors
  514. None.
  515. \SeeAlso
  516. \seef{mean},\seef{sum}, \seef{sumofsquares}, \seep{momentskewkurtosis}
  517. \end{procedure}
  518. \FPCexample{ex28}
  519. \begin{function}{min}
  520. \Declaration
  521. Function min(Int1,Int2:Cardinal):Cardinal;
  522. Function min(Int1,Int2:Integer):Integer;
  523. \Description
  524. \var{min} returns the smallest value of \var{Int1} and \var{Int2};
  525. \Errors
  526. None.
  527. \SeeAlso
  528. \seef{max}
  529. \end{function}
  530. \FPCexample{ex29}
  531. \begin{function}{minIntValue}
  532. \Declaration
  533. Function minIntValue(const Data: array of Integer): Integer;
  534. \Description
  535. \var{MinIntvalue} returns the smallest value in the \var{Data} array.
  536. This function is provided for \delphi compatibility, use \var{minvalue}
  537. instead.
  538. \Errors
  539. None
  540. \SeeAlso
  541. \seef{minvalue}, \seef{maxIntValue}, \seef{maxvalue}
  542. \end{function}
  543. \FPCexample{ex30}
  544. \begin{function}{minvalue}
  545. \Declaration
  546. Function minvalue(const data : array of float) : float;
  547. Function minvalue(const data : array of Integer) : Integer;
  548. Function minvalue(const data : PFloat; Const N : Integer) : float;
  549. Function minvalue(const data : PInteger; Const N : Integer) : Integer;
  550. \Description
  551. \var{Minvalue} returns the smallest value in the \var{data}
  552. array with integer or float values. The return value has
  553. the same type as the elements of the array.
  554. The third and fourth forms accept a pointer to an array of \var{N}
  555. integer or float values.
  556. \Errors
  557. None.
  558. \SeeAlso
  559. \seef{maxIntValue}, \seef{maxvalue}, \seef{minIntValue}
  560. \end{function}
  561. \FPCexample{ex31}
  562. \begin{procedure}{momentskewkurtosis}
  563. \Declaration
  564. procedure momentskewkurtosis(const data : array of float;
  565. var m1,m2,m3,m4,skew,kurtosis : float);
  566. procedure momentskewkurtosis(const data : PFloat; Const N : Integer;
  567. var m1,m2,m3,m4,skew,kurtosis : float);
  568. \Description
  569. \var{momentskewkurtosis} calculates the 4 first moments of the distribution
  570. of valuesin \var{data} and returns them in \var{m1},\var{m2},\var{m3} and
  571. \var{m4}, as well as the \var{skew} and \var{kurtosis}.
  572. \Errors
  573. None.
  574. \SeeAlso
  575. \seef{mean}, \seep{meanandstddev}
  576. \end{procedure}
  577. \FPCexample{ex32}
  578. \begin{function}{norm}
  579. \Declaration
  580. Function norm(const data : array of float) : float;
  581. Function norm(const data : PFloat; Const N : Integer) : float;
  582. \Description
  583. \var{Norm} calculates the Euclidian norm of the array of data.
  584. This equals \var{sqrt(sumofsquares(data))}.
  585. The second form accepts a pointer to an array of \var{N} values.
  586. \Errors
  587. None.
  588. \SeeAlso
  589. \seef{sumofsquares}
  590. \end{function}
  591. \FPCexample{ex33}
  592. \begin{function}{popnstddev}
  593. \Declaration
  594. Function popnstddev(const data : array of float) : float;
  595. Function popnstddev(const data : PFloat; Const N : Integer) : float;
  596. \Description
  597. \var{Popnstddev} returns the square root of the population variance of
  598. the values in the \var{Data} array. It returns zero if there is only one value.
  599. The second form of this function accepts a pointer to an array of \var{N}
  600. values.
  601. \Errors
  602. None.
  603. \SeeAlso
  604. \seef{popnvariance}, \seef{mean}, \seep{meanandstddev}, \seef{stddev},
  605. \seep{momentskewkurtosis}
  606. \end{function}
  607. \FPCexample{ex35}
  608. \begin{function}{popnvariance}
  609. \Declaration
  610. Function popnvariance(const data : array of float) : float;
  611. Function popnvariance(const data : PFloat; Const N : Integer) : float;
  612. \Description
  613. \var{Popnvariance} returns the square root of the population variance of
  614. the values in the \var{Data} array. It returns zero if there is only one value.
  615. The second form of this function accepts a pointer to an array of \var{N}
  616. values.
  617. \Errors
  618. None.
  619. \SeeAlso
  620. \seef{popnstddev}, \seef{mean}, \seep{meanandstddev}, \seef{stddev},
  621. \seep{momentskewkurtosis}
  622. \end{function}
  623. \FPCexample{ex36}
  624. \begin{function}{power}
  625. \Declaration
  626. Function power(base,exponent : float) : float;
  627. \Description
  628. \var{power} raises \var{base} to the power \var{power}. This is equivalent
  629. to \var{exp(power*ln(base))}. Therefore \var{base} should be non-negative.
  630. \Errors
  631. None.
  632. \SeeAlso
  633. \seef{intpower}
  634. \end{function}
  635. \FPCexample{ex34}
  636. \begin{function}{radtocycle}
  637. \Declaration
  638. Function radtocycle(rad : float) : float;
  639. \Description
  640. \var{Radtocycle} converts its argument \var{rad} (an angle expressed in
  641. radians) to an angle in cycles.
  642. (1 cycle equals 2 pi radians)
  643. \Errors
  644. None.
  645. \SeeAlso
  646. \seef{degtograd}, \seef{degtorad}, \seef{radtodeg},
  647. \seef{radtograd}, \seef{cycletorad}
  648. \end{function}
  649. \FPCexample{ex37}
  650. \begin{function}{radtodeg}
  651. \Declaration
  652. Function radtodeg(rad : float) : float;
  653. \Description
  654. \var{Radtodeg} converts its argument \var{rad} (an angle expressed in
  655. radians) to an angle in degrees.
  656. (180 degrees equals pi radians)
  657. \Errors
  658. None.
  659. \SeeAlso
  660. \seef{degtograd}, \seef{degtorad}, \seef{radtocycle},
  661. \seef{radtograd}, \seef{cycletorad}
  662. \end{function}
  663. \FPCexample{ex38}
  664. \begin{function}{radtograd}
  665. \Declaration
  666. Function radtograd(rad : float) : float;
  667. \Description
  668. \var{Radtodeg} converts its argument \var{rad} (an angle expressed in
  669. radians) to an angle in grads.
  670. (200 grads equals pi radians)
  671. \Errors
  672. None.
  673. \SeeAlso
  674. \seef{degtograd}, \seef{degtorad}, \seef{radtocycle},
  675. \seef{radtodeg}, \seef{cycletorad}
  676. \end{function}
  677. \FPCexample{ex39}
  678. \begin{function}{randg}
  679. \Declaration
  680. Function randg(mean,stddev : float) : float;
  681. \Description
  682. \var{randg} returns a random number which - when produced in large
  683. quantities - has a Gaussian distribution with mean \var{mean} and
  684. standarddeviation \var{stddev}.
  685. \Errors
  686. None.
  687. \SeeAlso
  688. \seef{mean}, \seef{stddev}, \seep{meanandstddev}
  689. \end{function}
  690. \FPCexample{ex40}
  691. \begin{procedure}{sincos}
  692. \Declaration
  693. Procedure sincos(theta : float;var sinus,cosinus : float);
  694. \Description
  695. \var{Sincos} calculates the sine and cosine of the angle \var{theta},
  696. and returns the result in \var{sinus} and \var{cosinus}.
  697. On Intel hardware, This calculation will be faster than making 2 calls
  698. to clculatet he sine and cosine separately.
  699. \Errors
  700. None.
  701. \SeeAlso
  702. \seef{arcsin}, \seef{arccos}.
  703. \end{procedure}
  704. \FPCexample{ex41}
  705. \begin{function}{sinh}
  706. \Declaration
  707. Function sinh(x : float) : float;
  708. \Description
  709. \var{Sinh} returns the hyperbolic sine of its argument \var{x}.
  710. \Errors
  711. \SeeAlso
  712. \seef{cosh}, \seef{arsinh}, \seef{tanh}, \seef{artanh}
  713. \end{function}
  714. \FPCexample{ex42}
  715. \begin{function}{stddev}
  716. \Declaration
  717. Function stddev(const data : array of float) : float;
  718. Function stddev(const data : PFloat; Const N : Integer) : float;
  719. \Description
  720. \var{Stddev} returns the standard deviation of the values in \var{Data}.
  721. It returns zero if there is only one value.
  722. The second form of the function accepts a pointer to an array of \var{N}
  723. values.
  724. \Errors
  725. None.
  726. \SeeAlso
  727. \seef{mean}, \seep{meanandstddev}, \seef{variance}, \seef{totalvariance}
  728. \end{function}
  729. \FPCexample{ex43}
  730. \begin{function}{sum}
  731. \Declaration
  732. Function sum(const data : array of float) : float;
  733. Function sum(const data : PFloat; Const N : Integer) : float;
  734. \Description
  735. \var{Sum} returns the sum of the values in the \var{data} array.
  736. The second form of the function accepts a pointer to an array of \var{N}
  737. values.
  738. \Errors
  739. None.
  740. \SeeAlso
  741. \seef{sumofsquares}, \seep{sumsandsquares}, \seef{totalvariance}
  742. , \seef{variance}
  743. \end{function}
  744. \FPCexample{ex44}
  745. \begin{function}{sumofsquares}
  746. \Declaration
  747. Function sumofsquares(const data : array of float) : float;
  748. Function sumofsquares(const data : PFloat; Const N : Integer) : float;
  749. \Description
  750. \var{Sumofsquares} returns the sum of the squares of the values in the \var{data}
  751. array.
  752. The second form of the function accepts a pointer to an array of \var{N}
  753. values.
  754. \Errors
  755. None.
  756. \SeeAlso
  757. \seef{sum}, \seep{sumsandsquares}, \seef{totalvariance}
  758. , \seef{variance}
  759. \end{function}
  760. \FPCexample{ex45}
  761. \begin{procedure}{sumsandsquares}
  762. \Declaration
  763. Procedure sumsandsquares(const data : array of float;
  764. var sum,sumofsquares : float);
  765. Procedure sumsandsquares(const data : PFloat; Const N : Integer;
  766. var sum,sumofsquares : float);
  767. \Description
  768. \var{sumsandsquares} calculates the sum of the values and the sum of
  769. the squares of the values in the \var{data} array and returns the
  770. results in \var{sum} and \var{sumofsquares}.
  771. The second form of the function accepts a pointer to an array of \var{N}
  772. values.
  773. \Errors
  774. None.
  775. \SeeAlso
  776. \seef{sum}, \seef{sumofsquares}, \seef{totalvariance}
  777. , \seef{variance}
  778. \end{procedure}
  779. \FPCexample{ex46}
  780. \begin{function}{tan}
  781. \Declaration
  782. Function tan(x : float) : float;
  783. \Description
  784. \var{Tan} returns the tangent of \var{x}.
  785. \Errors
  786. If \var{x} (normalized) is pi/2 or 3pi/2 then an overflow will occur.
  787. \SeeAlso
  788. \seef{tanh}, \seef{arcsin}, \seep{sincos}, \seef{arccos}
  789. \end{function}
  790. \FPCexample{ex47}
  791. \begin{function}{tanh}
  792. \Declaration
  793. Function tanh(x : float) : float;
  794. \Description
  795. \var{Tanh} returns the hyperbolic tangent of \var{x}.
  796. \Errors
  797. None.
  798. \SeeAlso
  799. \seef{arcsin}, \seep{sincos}, \seef{arccos}
  800. \end{function}
  801. \FPCexample{ex48}
  802. \begin{function}{totalvariance}
  803. \Declaration
  804. Function totalvariance(const data : array of float) : float;
  805. Function totalvariance(const data : PFloat; Const N : Integer) : float;
  806. \Description
  807. \var{TotalVariance} returns the total variance of the values in the
  808. \var{data} array. It returns zero if there is only one value.
  809. The second form of the function accepts a pointer to an array of \var{N}
  810. values.
  811. \Errors
  812. None.
  813. \SeeAlso
  814. \seef{variance}, \seef{stddev}, \seef{mean}
  815. \end{function}
  816. \FPCexample{ex49}
  817. \begin{function}{variance}
  818. \Declaration
  819. Function variance(const data : array of float) : float;
  820. Function variance(const data : PFloat; Const N : Integer) : float;
  821. \Description
  822. \var{Variance} returns the variance of the values in the
  823. \var{data} array. It returns zero if there is only one value.
  824. The second form of the function accepts a pointer to an array of \var{N}
  825. values.
  826. \Errors
  827. None.
  828. \SeeAlso
  829. \seef{totalvariance}, \seef{stddev}, \seef{mean}
  830. \end{function}
  831. \FPCexample{ex50}