(********************************************************************)
(*                                                                  *)
(*  math.s7i      Mathematical functions and constants              *)
(*  Copyright (C) 1993, 1994, 2005  Thomas Mertes                   *)
(*                                                                  *)
(*  This file is part of the Seed7 Runtime Library.                 *)
(*                                                                  *)
(*  The Seed7 Runtime Library is free software; you can             *)
(*  redistribute it and/or modify it under the terms of the GNU     *)
(*  Lesser General Public License as published by the Free Software *)
(*  Foundation; either version 2.1 of the License, or (at your      *)
(*  option) any later version.                                      *)
(*                                                                  *)
(*  The Seed7 Runtime Library is distributed in the hope that it    *)
(*  will be useful, but WITHOUT ANY WARRANTY; without even the      *)
(*  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *)
(*  PURPOSE.  See the GNU Lesser General Public License for more    *)
(*  details.                                                        *)
(*                                                                  *)
(*  You should have received a copy of the GNU Lesser General       *)
(*  Public License along with this program; if not, write to the    *)
(*  Free Software Foundation, Inc., 51 Franklin Street,             *)
(*  Fifth Floor, Boston, MA  02110-1301, USA.                       *)
(*                                                                  *)
(********************************************************************)


(**
 *  Mathematical constant π.
 *  ''PI'' is the ratio of any circle's circumference to its diameter.
 *)
const float: PI is 3.1415926535897932384626433832795028841971693993751058209749445923;


(**
 *  Euler's number.
 *  ''E'' is defined as exp(1.0)
 *)
const float: E  is 2.7182818284590452353602874713526624977572470936999595749669676277;


(**
 *  Compute the sine of x, where x is given in radians.
 *  @return the trigonometric sine of an angle.
 *)
const func float: sin (in float: x)                            is action "FLT_SIN";


(**
 *  Compute the cosine of x, where x is given in radians.
 *  @return the trigonometric cosine of an angle.
 *)
const func float: cos (in float: x)                            is action "FLT_COS";


(**
 *  Compute the tangent of x, where x is given in radians.
 *  @return the trigonometric tangent of an angle.
 *)
const func float: tan (in float: x)                            is action "FLT_TAN";


(**
 *  Compute the arc sine of x; that is the value whose sine is x.
 *  @return the arc sine of x in radians. The return angle is in the
 *          range [-PI/2, PI/2].
 *)
const func float: asin (in float: x)                           is action "FLT_ASIN";


(**
 *  Compute the arc cosine of x; that is the value whose cosine is x.
 *  @return the arc cosine of x in radians. The returned angle is in
 *          the range [0.0, PI].
 *)
const func float: acos (in float: x)                           is action "FLT_ACOS";


(**
 *  Compute the arc tangent of x; that is the value whose tangent is x.
 *  @return the arc tangent of x in radians. The returned angle is in
 *          the range [-PI/2, PI/2].
 *)
const func float: atan (in float: x)                           is action "FLT_ATAN";


(**
 *  Compute the arc tangent of y/x.
 *  The signs of x and y are used to determine the quadrant of the result.
 *  It determines the angle theta from the conversion of rectangular
 *  coordinates (x, y) to polar coordinates (r, theta).
 *  @return the arc tangent of y/x in radians. The returned angle is in
 *          the range [-PI, PI].
 *)
const func float: atan2 (in float: y, in float: x)             is action "FLT_ATAN2";


(**
 *  Compute the hyperbolic sine of x.
 *  sinh(x) is mathematically defined as: (exp(x) - exp(-x)) / 2.0
 *  @return the hyperbolic sine.
 *)
const func float: sinh (in float: x)                           is action "FLT_SINH";


(**
 *  Compute the hyperbolic cosine of x.
 *  cosh(x) is mathematically defined as: (exp(x) + exp(-x)) / 2.0
 *  @return the hyperbolic cosine.
 *)
const func float: cosh (in float: x)                           is action "FLT_COSH";


(**
 *  Compute the hyperbolic tangent of x.
 *  tanh(x) is mathematically defined as: sinh(x) / cosh(x)
 *  @return the hyperbolic tangent.
 *)
const func float: tanh (in float: x)                           is action "FLT_TANH";


(**
 *  Compute Euler's number e raised to the power of x.
 *  @return e raised to the power of x.
 *)
const func float: exp (in float: x)                            is action "FLT_EXP";


(**
 *  Return the natural logarithm (base e) of x.
 *  @return the natural logarithm of x.
 *)
const func float: log (in float: x)                            is action "FLT_LOG";


(**
 *  Returns the base 10 logarithm of x.
 *  @return the base 10 logarithm of x.
 *)
const func float: log10 (in float: x)                          is action "FLT_LOG10";


(**
 *  Returns the base 2 logarithm of x.
 *  @return the base 2 logarithm of x.
 *)
const func float: log2 (in float: x)                           is action "FLT_LOG2";


(**
 *  Returns the non-negative square root of x.
 *  @return the square root of x.
 *)
const func float: sqrt (in float: x)                           is action "FLT_SQRT";


(**
 *  Round up towards positive infinity.
 *  Determine the smallest value that is greater than or equal
 *  to the argument and is equal to a mathematical integer.
 *  @return the rounded value.
 *)
const func float: ceil (in float: x)                           is action "FLT_CEIL";


(**
 *  Round down towards negative infinity.
 *  Returns the largest value that is less than or equal to the
 *  argument and is equal to a mathematical integer.
 *  @return the rounded value.
 *)
const func float: floor (in float: x)                          is action "FLT_FLOOR";