
(********************************************************************)
(*                                                                  *)
(*  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;.
 *  ''PI'' is the ratio of any circle's circumference to its diameter.
 *)
const float: PI is 3.1415926535897932384626433832795028841972;


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


(**
 *  Compute the sine of x, where x is given in radians.
 *  @return the trigonometric sine of an angle.
 *)
const func float: sin (ref 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 (ref 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 (ref 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 (ref 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 (ref 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 (ref 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 (ref float: y, ref float: x)            is action "FLT_A2TAN";


(**
 *  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 (ref 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 (ref 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 (ref float: x)                           is action "FLT_TANH";


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


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


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


(**
 *  Returns the non-negative square root of x.
 *  @return the square root of x.
 *)
const func float: sqrt (ref 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 (ref 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 (ref float: x)                          is action "FLT_FLOOR";


(**
 *  Compute the absolute value of a float number.
 *  @return the absolute value.
 *)
const func float: abs (ref float: number)                       is action "FLT_ABS";
