Math Functions

Aurora has a large number of mathematics functions included as standard compiler and library functions. These functions can be grouped as follows:


Numeric/Algebraic Functions

Aurora has the following algebraic functions:



top of page


Absolute Value Function - ABS

otherdoublenum = ABS ( doublenum );

Description

  Returns the absolute value of a number.

Parameter:

  doublenum - double precision variable or number to take the absolute value of.

Return value:

  otherdoublenum - the absolute value is returned as a double precision number (double).

Usage:

absolutevalue = abs( -1.5 );

Remarks:

  In the example above,   abs(-1.5) = 1.5

Numeric / Algebraic Functions


top of page



Ceiling and Floor Functions - CEIL, FLOOR

otherdouble = CEIL ( doublenum );

otherdouble = FLOOR ( doublenum );

Description

  Ceil returns the smallest whole number (integer as a double precision) that is greater than or equal to the input parameter.

  Floor returns the largest whole number (integer as a double precision) that is less than or equal to the input parameter.

Parameter:

  doublenum - double precision variable or number to take the absolute value of.

Return value:

  otherdouble - the return value for both ceil and floor is a double precision whole number (double).

Usage:
   writeln("-2.5 is between "+ str$( ceil( -2.8 ) )+", "+str$(floor ( -2.8 ) )+"\n");
   writeln(" 2.5 is between  "+ str$( ceil( 2.8 ) )+",  "+str$(floor ( 2.8 ) )+"\n");
Remarks:

  In the examples above,   ceil(-2.8) = -2.0 ,   floor(-2.8) = -3.0 ,   ceil(2.8) = 3.0, and   floor(2.8) = 2.0

Numeric / Algebraic Functions


top of page



Random Number Generator Functions - SEEDRND, RAND, RND

SEEDRND ( intnum );

AnUnSignedInteger = RAND ( usint, optmaxi );

someRandomNum = RND ( num , optmaxf );

Description

  The SEEDRND function works with the RAND and RND functions. The SEEDRND function seeds the random number generator with a specific value.

  The RAND function creates a pseudo random number

         {Maximum random range is 0 <= number <= 65535}.

  The RND function creates a pseudo random number

         {Maximum random range is -32765.0 <= number <= 32766.0}.

Parameter:

  for SEEDRND intnum shall be an integer value (int)

  for RAND usint is the beginning or ending number for the range, and shall be an unsigned integer value (unsigned int),

  for RAND optmaxi is an optional interger value, that if given, the random number will be between num and optmaxi. Otherwise random number will be between 0 and num.

  for RND num shall be a floating point number value (float),

  for RND optmaxf is an optional floating point value, that if given, the random number will be between num and optmaxf. Otherwise random number will be between 0 and num.

Return value:

  There is no value returned for SEEDRND().

  AnUnSignedInteger - the pseudo random number returned for RAND() is an integer.

  someRandomNum - a pseudo random number returned for RND() is a single precision number (float).

Usage:

  //  random.src
  global sub main()
  {
   seedrnd ( 10021959 );
   writeln ( str$( rand ( 100, 25 ) ) + "\n" );
   writeln ( str$( rnd ( 15.5, 5.0 ) ) + "\n" );
   while (GetKey() = "");
   return;
  }

Remarks:

  On program execution the random number generator seed is set to the current Windows tick count guaranteeing that a repeating random sequence is unlikely to occur. If you use the same seed (by using the SEEDRND function) every time then the random sequence will be identical on successive runs.

Numeric / Algebraic Functions


top of page



Numberic Sign Function - SGN

intnum = SGN ( doublenum );

Description

  Returns the sign a number.

Parameter:

  doublenum - double precision variable or number to test.

Return value:

  SGN returns an integer -1 if the number is less than zero, 1 if the number is greater than zero, or 0 if the number equals zero.

Usage:
   // sign.src
   global sub main()
   {
     select sgn(-1.5)
        {
           case -1 : writeln ( " -1.5 is a negative number\n" );
           case  0 : writeln ( " -1.5 is a zero\n" );
           case  1 : writeln ( " -1.5 is a positive number\n" );
        }
     while (GetKey() = "");
     return;
   }
Remarks:

  In the example above,   sgn(-1.5) = -1

Numeric / Algebraic Functions


top of page



Square Root Function - SQRT

otherdoublenum = SQRT ( doublenum );

Description

  Returns the square root of a number.

Parameter:

  doublenum - double precision variable or number that the square root is taken of.

Return value:

  SQRT returns a double precision number (double).

Usage:
   writeln ( "the square root of 25 is " + str$( sqrt( 25.0 ) ) );
Remarks:

  In the examples above,   sqrt(25.0) = 5.0. Please note that taking the square root of a negative number results in an error and may cause unpredictable results.

Numeric / Algebraic Functions


top of page



Trigonometric Functions

Aurora has the following trigonometric functions:


Sine Functions - SIN, SIND, FSIN, FSIND

doublenum = SIN ( doubleradian );

doublenum = SIND ( doubledegree );

floatnum = FSIN ( singleradian );

floatnum = FSIND ( singledegree );

Description

  These functions all return the sine of an angle.

    SIN returns a double precision sine value of an angle in radians (double).

    SIND returns a double precision sine value of an angle in degrees (double).

    FSIN returns a single precision (float) sine value of an angle in radians (float).

    FSIND returns a single precision (float) sine value of an angle in degrees (float).

Parameter:

  doubleradian - double precision variable (double) or number in radians.

  doubledegree - double precision variable (double) or number in degrees.

  singleradian - single precision variable (float) or number in radians.

  singledegree - single precision variable (float) or number in degrees.

Return value:

  doublenum is a double precision number (double),   floatnum is a single precision number (float).

Usage:
  //  sine.src 
  global sub main() 
  { 
    writeln("Sine of PI/2 radians = " + str$( sin( 3.1416/2 ), 2)+"\n");
    writeln("Sine of 90.0 degrees = " + str$( sind( 90.0000 ), 2)+"\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   sin(3.1416/2) = 1.00 and sind(90.0) = 1.00

  pi = 3.14159265358979323846264338327950288419716939937511

Trigonometric Functions


top of page



Cosine Functions - COS, COSD, FCOS, FCOSD

doublenum = COS ( doubleradian );

doublenum = COSD ( doubledegree );

floatnum = FCOS ( singleradian );

floatnum = FCOSD ( singledegree );

Description

  These functions all return the cosine of an angle.

    COS returns a double precision cosine value of an angle in radians (double).

    COSD returns a double precision cosine value of an angle in degrees (double).

    FCOS returns a single precision (float) cosine value of an angle in radians (float).

    FCOSD returns a single precision (float) cosine value of an angle in degrees (float).

Parameter:

  doubleradian - double precision variable (double) or number in radians.

  doubledegree - double precision variable (double) or number in degrees.

  singleradian - single precision variable (float) or number in radians.

  singledegree - single precision variable (float) or number in degrees.

Return value:

  doublenum is a double precision number (double),   floatnum is a single precision number (float).

Usage:
  //  cosine.src 
  global sub main() 
  { 
    writeln("Cosine of PI/2 radians = " + str$( cos( 3.1416/2 ), 2)+"\n");
    writeln("Cosine of 90.0 degrees = " + str$( cosd( 90.0000 ), 2)+"\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   cos(3.1416/2) = 0.00 and cosd(90.0) = 0.00

  pi = 3.14159265358979323846264338327950288419716939937511

Trigonometric Functions


top of page



Tangent Functions - TAN, TAND, FTAN, FTAND

doublenum = TAN ( doubleradian );

doublenum = TAND ( doubledegree );

floatnum = FTAN ( singleradian );

floatnum = FTAND ( singledegree );

Description

  These functions all return the tangent of an angle.

    TAN returns a double precision tangent value of an angle in radians (double).

    TAND returns a double precision tangent value of an angle in degrees (double).

    FTAN returns a single precision (float) tangent value of an angle in radians (float).

    FTAND returns a single precision (float) tangent value of an angle in degrees (float).

Parameter:

  doubleradian - double precision variable (double) or number in radians.

  doubledegree - double precision variable (double) or number in degrees.

  singleradian - single precision variable (float) or number in radians.

  singledegree - single precision variable (float) or number in degrees.

Return value:

  doublenum is a double precision number (double),   floatnum is a single precision number (float).

Usage:
  //  tangent.src 
  global sub main() 
  { 
    writeln("Tangent of PI/4 radians = " + str$( tan( 3.1416/4 ), 2)+"\n");
    writeln("Tangent of 45.0 degrees = " + str$( tand( 45.0000 ), 2)+"\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   tan(3.1416/4) = 1.00 and tand(45.0) = 1.00

  pi = 3.14159265358979323846264338327950288419716939937511

Trigonometric Functions


top of page



Arcsine Functions - ASIN, ASIND, FASIN, FASIND

doubleradian = ASIN ( doublenum );

doubledegree = ASIND ( doublenum );

singleradian = FASIN ( floatnum );

singledegree = FASIND ( floatnum );

Description

  These functions all return the Arcsine of an angle.

    ASIN returns a double precision Arcsine value of an angle in radians (double).

    ASIND returns a double precision Arcsine value of an angle in degrees (double).

    FASIN returns a single precision (float) Arcsine value of an angle in radians (float).

    FASIND returns a single precision (float) Arcsine value of an angle in degrees (float).

Parameters:

  doublenum is a double precision number (double)

  floatnum is a single precision number (float).

Return values:

  doubleradian - double precision variable or number in radians.

  doubledegree - double precision variable or number in degrees.

  singleradian - single precision variable or number in radians.

  singledegree - single precision variable or number in degrees.

Usage:
  //  arcsine.src 
  global sub main() 
  { 
    writeln("Arcsine of 1.0 = " + str$( ASIN( 1.0 ), 3)+" radians\n");
    writeln("Arcsine of 1.0 = " + str$( ASIND( 1.0 ), 2)+" degrees\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   ASIN(1.0) = 1.571 radians and ASIND(1.0) = 90.00 degrees

  pi = 3.14159265358979323846264338327950288419716939937511

Trigonometric Functions


top of page



Arccosine Functions - ACOS, ACOSD,FACOS,FACOSD

doubleradian = ACOS ( doublenum );

doubledegree = ACOSD ( doublenum );

singleradian =FACOS ( floatnum );

singledegree =FACOSD ( floatnum );

Description

  These functions all return the Arccosine of an angle.

    ASIN returns a double precision Arccosine value of an angle in radians (double).

    ASIND returns a double precision Arccosine value of an angle in degrees (double).

    FASIN returns a single precision (float) Arccosine value of an angle in radians (float).

    FASIND returns a single precision (float) Arccosine value of an angle in degrees (float).

Parameters:

  doublenum is a double precision number (double)

  floatnum is a single precision number (float).

Return values:

  doubleradian - double precision variable or number in radians.

  doubledegree - double precision variable or number in degrees.

  singleradian - single precision variable or number in radians.

  singledegree - single precision variable or number in degrees.

Usage:
  //  arccosine.src 
  global sub main() 
  { 
    writeln("Arccosine of 0.0 = " + str$( ACOS( 0.0 ), 3)+" radians\n");
    writeln("Arccosine of 0.0 = " + str$( ACOSD( 0.0 ), 2)+" degrees\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   ACOS(1.0) = 1.571 radians and ACOSD(1.0) = 90.00 degrees

  pi = 3.14159265358979323846264338327950288419716939937511

Trigonometric Functions


top of page



Arctangent Functions - ATAN, ATAND,FATAN,FATAND

doubleradian = ATAN ( doublenum );

doubledegree = ATAND ( doublenum );

singleradian =FATAN ( floatnum );

singledegree =FATAND ( floatnum );

Description

  These functions all return the Arctangent of an angle.

    ASIN returns a double precision Arctangent value of an angle in radians (double).

    ASIND returns a double precision Arctangent value of an angle in degrees (double).

    FASIN returns a single precision (float) Arctangent value of an angle in radians (float).

    FASIND returns a single precision (float) Arctangent value of an angle in degrees (float).

Parameters:

  doublenum is a double precision number (double)

  floatnum is a single precision number (float).

Return values:

  doubleradian - double precision variable or number in radians.

  doubledegree - double precision variable or number in degrees.

  singleradian - single precision variable or number in radians.

  singledegree - single precision variable or number in degrees.

Usage:
  //  arctangent.src 
  global sub main() 
  { 
    writeln("Arctangent of 1.0 = " + str$( ATAN( 1.0 ), 3)+" radians\n");
    writeln("Arctangent of 1.0 = " + str$( ATAND( 1.0 ), 2)+" degrees\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   ATAN(1.0) = 0.785 radians and ATAND(1.0) = 45.00 degrees

  pi = 3.14159265358979323846264338327950288419716939937511

Trigonometric Functions


top of page



Logarithmic and Exponential Functions

Aurora has the following logarithmic and Exponential functions:


Natural Log Function ( ln = Log Base e ) - LOG

otherdoublenum = LOG ( doublenum );

Description

    Calculates the Natural Logarithm ( ln = Log Base e ) of a number.

    Note: e = 2.71828182845904523536028747135266249775724709369996...

Parameters:

  doublenum is a double precision number (double) must be greater than zero.

Return values:

  otherdoublenum - double precision variable or number.

Usage:
  //  log.src 
  global sub main() 
  { writeln("Natural Log (ln) of 10.0 = " + str$( LOG( 10.0 ), 4) + "\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   LOG(10.0) = 2.3026

  The logarithm of a number unless the number is less than or equal to zero. If the input is less than zero then the result is indefinite (undefined). If the input is equal to zero then the result is infinite (undefined) and cannot be represented.

Logarithmic and Exponential Functions


top of page



Log Base 10 Function - LOG10

otherdoublenum = LOG10 ( doublenum );

Description

    Calculates the Base 10 Logarithm of a number.

Parameters:

  doublenum is a double precision number (double) must be greater than zero.

Return values:

  otherdoublenum - double precision variable or number.

Usage:
  //  log10.src 
  global sub main() 
  { writeln("Natural Log Base 10 of 10.0 = " + str$( LOG10( 10.0 ), 4) + "\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   LOG(10.0) = 1.0000

  The logarithm of a number unless the number is less than or equal to zero. If the input is less than zero then the result is indefinite (undefined). If the input is equal to zero then the result is infinite (undefined) and cannot be represented.

Logarithmic and Exponential Functions


top of page



Exponential Function (e^x) - EXP

otherdoublenum = EXP ( doublenum );

Description

    Calculates a positive double precision number (double) equal to e raised to the doublenum power (e^doublenum).

    Note: e = 2.71828182845904523536028747135266249775724709369996...

Parameters:

  doublenum is a double precision number (double) must be greater than zero.

Return values:

  otherdoublenum - double precision variable or number (double).

Usage:
  //  exp.src 
  global sub main() 
  { writeln("e^2 = " + str$( EXP( 2.0 ), 4) + "\n");
    while (GetKey() = "");
    return;
  }
Remarks:

  In the examples above,   EXP(2.0) = 7.3891


Logarithmic and Exponential Functions


top of page



Hyperbolic Functions

Hyperbolic functions are functions which involve exponents of e (e^x) such as:

SINH(x) = FSINH(x) = (e^(x) - e^(-x)) / 2   and   COSH(x) = FCOSH(x) = (e^(x) + e^(-x)) / 2

Aurora has the following Hyperbolic functions:


Hyperbolic Sine Function - SINH, FSINH

otherdoublenum = SINH ( doublenum );

othersinglenum = FSINH ( singlenum );

Description

    SINH calculates a double precision number (double) equal to the Hyperbolic Sine of a double number (double)

    FSINH calculates a single precision number (float) equal to the Hyperbolic Sine of a single number (float)

     SINH(x) = FSINH(x) = (e^(x) - e^(-x)) / 2

    Note: e = 2.71828182845904523536028747135266249775724709369996...

Parameters:

  doublenum is a double precision variable or number (double).

  singlenum is a single precision variable or number (float).

Return values:

  otherdoublenum - double precision variable or number (double).

  othersinglenum - single precision variable or number (float).

Usage:
  //  sinh.src 
  global sub main() 
  {
    double x;
     for ( x = -10; x <= 10; x++ )  // For Loop, x= -10 to 10, increment (step) x by 1
      {
        writeln("x = " + str$( x ) + " , ");
        writeln("SINH(x) = " + str$( sinh( x ), 2 ) + "\n");
      }
    while (GetKey() = "");
    return;
  }
Remarks:

  In the example above,   sinh(-10.0) = -11013.23, sinh(0.0) = 0.0, sinh(10.0) = 11013.23

Hyperbolic Functions


top of page



Hyperbolic Cosine Function - COSH, FCOSH

otherdoublenum = COSH ( doublenum );

othersinglenum = FCOSH ( singlenum );

Description

    COSH calculates a double precision number (double) equal to the Hyperbolic Cosine of a double number (double)

    FCOSH calculates a single precision number (float) equal to the Hyperbolic Cosine of a single number (float)

     COSH(x) = FCOSH(x) = (e^(x) + e^(-x)) / 2

    Note: e = 2.71828182845904523536028747135266249775724709369996...

Parameters:

  doublenum is a double precision variable or number (double).

  singlenum is a single precision variable or number (float).

Return values:

  otherdoublenum - double precision variable or number (double).

  othersinglenum - single precision variable or number (float).

Usage:
  //  cosh.src 
  global sub main() 
  {
    double x;
     for ( x = -10; x <= 10; x++ )  // For Loop, x= -10 to 10, increment (step) x by 1
      {
        writeln("x = " + str$( x ) + " , ");
        writeln("COSH(x) = " + str$( cosh( x ), 2 ) + "\n");
      }
    while (GetKey() = "");
    return;
  }
Remarks:

  In the example above,   cosh(-10.0) = 11013.23, cosh(0.0) = 1.0, cosh(10.0) = 11013.23

Hyperbolic Functions


top of page



Hyperbolic Tangent Function - TANH, FTANH

otherdoublenum = TANH ( doublenum );

othersinglenum = FTANH ( singlenum );

Description

    TANH calculates a double precision number (double) equal to the Hyperbolic Tangent of a double number (double)

    FTANH calculates a single precision number (float) equal to the Hyperbolic Tangent of a single number (float)

    Note: TANH(x) = SINH(x) / COSH(x) , FTANH(x) = FSINH(x) / FCOSH(x)

Parameters:

  doublenum is a double precision variable or number (double).

  singlenum is a single precision variable or number (float).

Return values:

  otherdoublenum - double precision variable or number (double).

  othersinglenum - single precision variable or number (float).

Usage:
  //  tanh.src 
  global sub main() 
  {
    double x;
     for ( x = -10; x <= 10; x++ )  // For Loop, x= -10 to 10, increment (step) x by 1
      {
        writeln("x = " + str$( x ) + " , ");
        writeln("TANH(x) = " + str$( tanh( x ), 2 ) + "\n");
      }
    while (GetKey() = "");
    return;
  }
Remarks:

  In the example above,   tanh(-10.0) = -1.00, tanh(0.0) = 0.0, tanh(10.0) = 1.00


Hyperbolic Functions


top of page


prev


next