Browse Source

+ Added many functions

michael 25 years ago
parent
commit
8932d13ffa
1 changed files with 132 additions and 80 deletions
  1. 132 80
      docs/math.tex

+ 132 - 80
docs/math.tex

@@ -37,17 +37,19 @@ The following types are defined in the \file{math} unit:
 Type
 Type
    Float = Extended;
    Float = Extended;
 \end{verbatim}
 \end{verbatim}
-
+All calculations are done with the Float type. This allows to
+recompile the unit with a different float type to obtain a
+desired precision.
 \begin{verbatim}
 \begin{verbatim}
 Type
 Type
    TPaymentTime = (PTEndOfPeriod,PTStartOfPeriod);
    TPaymentTime = (PTEndOfPeriod,PTStartOfPeriod);
 \end{verbatim}
 \end{verbatim}
-
+\var{TPaymentTime} is used in the financial calculations.
 \begin{verbatim}
 \begin{verbatim}
 Type
 Type
    EInvalidArgument = Class(EMathError);
    EInvalidArgument = Class(EMathError);
 \end{verbatim}
 \end{verbatim}
-
+The \var{EInvalidArgument} exception is used to report invalid arguments.
 \section{Functions and Procedures}
 \section{Functions and Procedures}
 
 
 \begin{function}{arccos}
 \begin{function}{arccos}
@@ -57,10 +59,10 @@ Function arccos(x : float) : float;
 \var{Arccos} returns the inverse cosine of its argument \var{x}. The
 \var{Arccos} returns the inverse cosine of its argument \var{x}. The
 argument \var{x} should lie between -1 and 1 (borders included). 
 argument \var{x} should lie between -1 and 1 (borders included). 
 \Errors
 \Errors
-If the argument \var{x} is not in the allowed range, an \var{EMathError}
-exception is raised.
+If the argument \var{x} is not in the allowed range, an
+\var{EInvalidArgument} exception is raised.
 \SeeAlso
 \SeeAlso
-\seef{arcsin}, \seef{arcosh}, \seef{arsinh}, \seef{arctanh}
+\seef{arsin}, \seef{arcosh}, \seef{arsinh}, \seef{artanh}
 \end{function}
 \end{function}
 
 
 \FPCexample{ex1}
 \FPCexample{ex1}
@@ -76,10 +78,10 @@ The argument \var{x} should be larger than 1.
 The \var{arccosh} variant of this function is supplied for \delphi 
 The \var{arccosh} variant of this function is supplied for \delphi 
 compatibility.
 compatibility.
 \Errors
 \Errors
-If the argument \var{x} is not in the allowed range, an \var{EMathError}
+If the argument \var{x} is not in the allowed range, an \var{EInvalidArgument}
 exception is raised.
 exception is raised.
 \SeeAlso
 \SeeAlso
-\seef{cosh}, \seef{sinh}, \seef{arcsin}, \seef{arcsinh}, \seef{arctanh},
+\seef{cosh}, \seef{sinh}, \seef{arsin}, \seef{arsinh}, \seef{artanh},
 \seef{tanh}
 \seef{tanh}
 \end{function}
 \end{function}
 
 
@@ -92,10 +94,10 @@ Function arcsin(x : float) : float;
 \var{Arcsin} returns the inverse sine of its argument \var{x}. The
 \var{Arcsin} returns the inverse sine of its argument \var{x}. The
 argument \var{x} should lie between -1 and 1. 
 argument \var{x} should lie between -1 and 1. 
 \Errors
 \Errors
-If the argument \var{x} is not in the allowed range, an \var{EMathError}
+If the argument \var{x} is not in the allowed range, an \var{EInvalidArgument}
 exception is raised.
 exception is raised.
 \SeeAlso
 \SeeAlso
-\seef{arccos}, \seef{arccosh}, \seef{arcsinh}, \seef{arctanh}
+\seef{arcos}, \seef{arcosh}, \seef{arsinh}, \seef{artanh}
 \end{function}
 \end{function}
 
 
 \FPCexample{ex2}
 \FPCexample{ex2}
@@ -116,23 +118,10 @@ On Intel systems this function is implemented with the native intel
 \Errors
 \Errors
 If \var{x} is zero, an overflow error will occur.
 If \var{x} is zero, an overflow error will occur.
 \SeeAlso
 \SeeAlso
-\seef{arccos}, \seef{arccosh}, \seef{arcsinh}, \seef{arctanh}
+\seef{arcos}, \seef{arcosh}, \seef{arsinh}, \seef{artanh}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
-
-
-\begin{function}{arctanh}
-\Declaration
-Function arctanh(x : float) : float;
-\Description
-
-\Errors
-\SeeAlso
-\end{function}
-
-\FPCexample{}
-
+\FPCexample{ex6}
 
 
 \begin{function}{arsinh}
 \begin{function}{arsinh}
 \Declaration
 \Declaration
@@ -146,7 +135,7 @@ compatibility.
 \Errors
 \Errors
 None.
 None.
 \SeeAlso
 \SeeAlso
-\seef{arccosh}, \seef{arccos}, \seef{arsin}, \seef{artanh}
+\seef{arcosh}, \seef{arcos}, \seef{arsin}, \seef{artanh}
 \end{function}
 \end{function}
 
 
 \FPCexample{ex4}
 \FPCexample{ex4}
@@ -155,251 +144,315 @@ None.
 \begin{function}{artanh}
 \begin{function}{artanh}
 \Declaration
 \Declaration
 Function artanh(x : float) : float;
 Function artanh(x : float) : float;
+Function arctanh(x : float) : float;
 \Description
 \Description
+\var{artanh} returns the inverse hyperbolic tangent of its argument \var{x},
+where \var{x} should lie in the interval [-1,1], borders included.
 
 
+The \var{arctanh} variant of this function is supplied for \delphi compatibility.
+\Errors
+In case \var{x} is not in the interval [-1,1], an \var{EInvalidArgument}
+exception is raised.
+\SeeAlso
+\seef{arcosh}, \seef{arcos}, \seef{arsin}, \seef{artanh}
 \Errors
 \Errors
 \SeeAlso
 \SeeAlso
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex5}
 
 
 
 
 \begin{function}{ceil}
 \begin{function}{ceil}
 \Declaration
 \Declaration
 Function ceil(x : float) : longint;
 Function ceil(x : float) : longint;
 \Description
 \Description
-
+\var{Ceil} returns the lowest integer number greater than or equal to \var{x}.
+The absolute value of \var{x} should be less than \var{maxint}.
 \Errors
 \Errors
+If the asolute value of \var{x} is larger than maxint, an overflow error will
+occur.
 \SeeAlso
 \SeeAlso
+\seef{floor}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
-
+\FPCexample{ex7}
 
 
 \begin{function}{cosh}
 \begin{function}{cosh}
 \Declaration
 \Declaration
 Function cosh(x : float) : float;
 Function cosh(x : float) : float;
 \Description
 \Description
-
+\var{Cosh} returns the hyperbolic cosine of it's argument {x}.
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{arcosh}, \seef{sinh}, \seef{arsinh}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex8}
 
 
 
 
 \begin{function}{cotan}
 \begin{function}{cotan}
 \Declaration
 \Declaration
 Function cotan(x : float) : float;
 Function cotan(x : float) : float;
 \Description
 \Description
-
+\var{Cotan} returns the cotangent of it's argument \var{x}. \var{x} should
+be different from zero.
 \Errors
 \Errors
+If \var{x} is zero then a overflow error will occur.
 \SeeAlso
 \SeeAlso
+\seef{tanh}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex9}
 
 
 
 
 \begin{function}{cycletorad}
 \begin{function}{cycletorad}
 \Declaration
 \Declaration
 Function cycletorad(cycle : float) : float;
 Function cycletorad(cycle : float) : float;
 \Description
 \Description
-
+\var{Cycletorad} transforms it's argument \var{cycle}
+(an angle expressed in cycles) to radians.
+(1 cycle is $2 \pi$ radians).
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{degtograd}, \seef{degtorad}, \seef{radtodeg},
+\seef{radtograd}, \seef{radtocycle}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex10}
 
 
 
 
 \begin{function}{degtograd}
 \begin{function}{degtograd}
 \Declaration
 \Declaration
 Function degtograd(deg : float) : float;
 Function degtograd(deg : float) : float;
 \Description
 \Description
+\var{Degtograd} transforms it's argument \var{deg} (an angle in degrees)
+to grads.
 
 
+(90 degrees is 100 grad.)
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{cycletorad}, \seef{degtorad}, \seef{radtodeg},
+\seef{radtograd}, \seef{radtocycle}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex11}
 
 
 
 
 \begin{function}{degtorad}
 \begin{function}{degtorad}
 \Declaration
 \Declaration
 Function degtorad(deg : float) : float;
 Function degtorad(deg : float) : float;
 \Description
 \Description
+\var{Degtorad} converts it's argument \var{deg} (an angle in degrees) to
+radians.
 
 
+(pi radians is 180 degrees)
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{cycletorad}, \seef{degtograd}, \seef{radtodeg},
+\seef{radtograd}, \seef{radtocycle}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex12}
 
 
 
 
 \begin{function}{floor}
 \begin{function}{floor}
 \Declaration
 \Declaration
 Function floor(x : float) : longint;
 Function floor(x : float) : longint;
 \Description
 \Description
-
+\var{Floor} returns the largest integer smaller than or equal to \var{x}.
+The absolute value of \var{x} should be less than \var{maxint}.
 \Errors
 \Errors
+If \var{x} is larger than \var{maxint}, an overflow will occur.
 \SeeAlso
 \SeeAlso
+\seef{ceil}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex13}
 
 
 
 
 \begin{procedure}{frexp}
 \begin{procedure}{frexp}
 \Declaration
 \Declaration
 Procedure frexp(x : float;var mantissa,exponent : float);
 Procedure frexp(x : float;var mantissa,exponent : float);
 \Description
 \Description
-
+\var{Frexp} returns the mantissa and exponent of it's argument
+\var{x} in \var{mantissa} and \var{exponent}.
 \Errors
 \Errors
+None
 \SeeAlso
 \SeeAlso
 \end{procedure}
 \end{procedure}
 
 
-\FPCexample{}
+\FPCexample{ex14}
 
 
 
 
 \begin{function}{gradtodeg}
 \begin{function}{gradtodeg}
 \Declaration
 \Declaration
 Function gradtodeg(grad : float) : float;
 Function gradtodeg(grad : float) : float;
 \Description
 \Description
+\var{Gradtodeg} converts its argument \var{grad} (an angle in grads)
+to degrees.
 
 
+(100 grad is 90 degrees)
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{cycletorad}, \seef{degtograd}, \seef{radtodeg},
+\seef{radtograd}, \seef{radtocycle}, \seef{gradtorad}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex15}
 
 
 
 
 \begin{function}{gradtorad}
 \begin{function}{gradtorad}
 \Declaration
 \Declaration
 Function gradtorad(grad : float) : float;
 Function gradtorad(grad : float) : float;
 \Description
 \Description
+\var{Gradtorad} converts its argument \var{grad} (an angle in grads)
+to radians.
 
 
+(200 grad is pi degrees).
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{cycletorad}, \seef{degtograd}, \seef{radtodeg},
+\seef{radtograd}, \seef{radtocycle}, \seef{gradtodeg}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex16}
 
 
 
 
 \begin{function}{hypot}
 \begin{function}{hypot}
 \Declaration
 \Declaration
 Function hypot(x,y : float) : float;
 Function hypot(x,y : float) : float;
 \Description
 \Description
+\var{Hypot} returns the hypotenuse of the triangle where the sides
+adjacent to the square angle have lengths \var{x} and \var{y}.
 
 
+The function uses Pythagoras' rule for this.
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex17}
 
 
 
 
 \begin{function}{intpower}
 \begin{function}{intpower}
 \Declaration
 \Declaration
 Function intpower(base : float;exponent : longint) : float;
 Function intpower(base : float;exponent : longint) : float;
 \Description
 \Description
-
+\var{Intpower} returns \var{base} to the power \var{exponent},
+where exponent is an integer value.
 \Errors
 \Errors
+If \var{base} is zero and the exponent is negative, then an
+overflow error will occur.
 \SeeAlso
 \SeeAlso
+\seef{power}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex18}
 
 
 
 
 \begin{function}{ldexp}
 \begin{function}{ldexp}
 \Declaration
 \Declaration
 Function ldexp(x : float;p : longint) : float;
 Function ldexp(x : float;p : longint) : float;
 \Description
 \Description
-
+\var{Ldexp} returns $2^p x$.
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{lnxp1}, \seef{log10},\seef{log2},\seef{logn}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex19}
 
 
 
 
-\begin{function}{lnxpi}
+\begin{function}{lnxp1}
 \Declaration
 \Declaration
-Function lnxpi(x : float) : float;
+Function lnxp1(x : float) : float;
 \Description
 \Description
-
+\var{Lnxp1} returns the natural logarithm of \var{1+X}. The result
+is more precise for small values of \var{x}. \var{x} should be larger
+than -1.
 \Errors
 \Errors
+If $x\leq -1$ then an \var{EInvalidArgument} exception will be raised.
 \SeeAlso
 \SeeAlso
+\seef{ldexp}, \seef{log10},\seef{log2},\seef{logn}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
-
+\FPCexample{ex20}
 
 
 \begin{function}{log10}
 \begin{function}{log10}
 \Declaration
 \Declaration
 Function log10(x : float) : float;
 Function log10(x : float) : float;
 \Description
 \Description
-
+\var{Log10} returns the 10-base logarithm of \var{X}.
 \Errors
 \Errors
+If \var{x} is less than or equal to 0 an 'invalid fpu operation' error
+will occur.
 \SeeAlso
 \SeeAlso
+\seef{ldexp}, \seef{lnxp1},\seef{log2},\seef{logn}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex21}
 
 
 
 
 \begin{function}{log2}
 \begin{function}{log2}
 \Declaration
 \Declaration
 Function log2(x : float) : float;
 Function log2(x : float) : float;
 \Description
 \Description
-
+\var{Log2} returns the 2-base logarithm of \var{X}.
 \Errors
 \Errors
+If \var{x} is less than or equal to 0 an 'invalid fpu operation' error
+will occur.
 \SeeAlso
 \SeeAlso
+\seef{ldexp}, \seef{lnxp1},\seef{log10},\seef{logn}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex22}
 
 
 
 
 \begin{function}{logn}
 \begin{function}{logn}
 \Declaration
 \Declaration
 Function logn(n,x : float) : float;
 Function logn(n,x : float) : float;
 \Description
 \Description
-
+\var{Logn} returns the n-base logarithm of \var{X}.
 \Errors
 \Errors
+If \var{x} is less than or equal to 0 an 'invalid fpu operation' error
+will occur.
 \SeeAlso
 \SeeAlso
+\seef{ldexp}, \seef{lnxp1},\seef{log10},\seef{log2}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
+\FPCexample{ex23}
 
 
-
-  var m1,m2,m3,m4,skew,kurtosis : float);
 \begin{function}{max}
 \begin{function}{max}
 \Declaration
 \Declaration
 Function max(Int1,Int2:Cardinal):Cardinal;
 Function max(Int1,Int2:Cardinal):Cardinal;
-\Description
-
-\Errors
-\SeeAlso
-\end{function}
-
-\FPCexample{}
-
-
-\begin{function}{max}
-\Declaration
 Function max(Int1,Int2:Integer):Integer;
 Function max(Int1,Int2:Integer):Integer;
 \Description
 \Description
-
+\var{Max} returns the the maximum of \var{Int1} and \var{Int2}.
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{min}, \seef{maxIntValue}, \seef{\maxvalue}
 \end{function}
 \end{function}
 
 
-\FPCexample{}
-
+\FPCexample{ex24}
 
 
 \begin{function}{maxIntValue}
 \begin{function}{maxIntValue}
 \Declaration
 \Declaration
-Function maxIntValue(const Data: array of Integer): Integer;
+function MaxIntValue(const Data: array of Integer): Integer;
 \Description
 \Description
-
+\var{MaxIntValue} returns the biggest integer out of the \var{Data}
+array.
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
+\seef{maxvalue}, \seef{minvalue}, \seef{minIntValue}
 \end{function}
 \end{function}
 
 
 \FPCexample{}
 \FPCexample{}
@@ -716,5 +769,4 @@ Function variance(const data : array of float) : float;
 \SeeAlso
 \SeeAlso
 \end{function}
 \end{function}
 
 
-\FPCexample{}
-
+\FPCexample{}