FACT()

FACT()

Calculates faculty

Syntax

      FACT( <nNumber> ) -> nFaculty

Arguments

<nNumber> number between 0 and 21

Returns

<nFaculty> the faculty of <nNumber>

Description

The function FACT() calculates the faculty to the integer given in <nNumber>. The faculty is defined as n! = 1*2*…*n and is often used in statistics. Note, that faculties above 21 are too big so that the function must return a -1.

Examples

      ? fact( 0 ) // --> 1
      ? fact( 1 ) // --> 1
      ? fact( 4 ) // --> 24

Tests

      fact( 0 ) == 1
      fact( 1 ) == 1
      fact( 4 ) == 24

Compliance

FACT() is compatible with CT3’s FACT().

Platforms

All

Files

Source is math.c, library is libct.

COT()

COT()

Cotangent of the argument

Syntax

      COT( nRadiant ) -> nCotangent

Arguments

<nRadiant> an angle size given in radiants

Returns

<nCotangent> the cotangent of <nRadiant>

Description

The function COT() calculates the cotangent of an angle whose size is given in radiants (full angle equals 2*Pi – see DTOR() for angle size given in degress). A common geometric interpretation of the COT() function is the ankathede-counterkathede-ratio of a right-angled triangle, or, cot(x) = cos(x)/sin(x)=1/tan(x).

Examples

      ? cot( 1.0 ) // --> 0.6420...

Tests

      cot( PI() / 4 ) == 1
      cot( PI() / 2 ) == 0

Compliance

COT() is compatible with CT3’s COT().

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), COS(), TAN(), ASIN(), ACOS(), ATAN(), ATN2(), SINH(), COSH(), TANH(), RTOD(), DTOR(), PI()

COSH()

COSH()

Hyperbolic Cosine of the argument

Syntax

      COSH( nArea ) -> nHyperbolicCosine

Arguments

<nArea> the size of the area (see below)

Returns

<nHyperbolicCosine> the hyperbolic cosine of <nArea>

Description

The function COSH() calculates the hyperbolic cosine of the argument. In analytical mathematics it is defined as 1/2*(exp(nArea)+exp(-nArea)). A common geometric interpretation of the COSH() function is the maximum x value of the points in the area with the given size <nArea>, that is bound by the x axis, a straight line through the point of origin (this one is fixed by the area) and the hyperbola xˆ2-yˆ2=1.

Examples

      ? cosh( 0.0 ) // --> 1.0
      ? cosh( 1.0 ) // --> 1.5430...

Tests

      cosh( 0.0 ) == 1.0
      cosh( -0.5 ) == cosh( 0.5 )

Compliance

COSH() is new in Harbours CT3’s library.

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), COS(), TAN(), COT(), ASIN(), ACOS(), ATAN(), ATN2(), SINH(), TANH(), RTOD(), DTOR(), PI()

COS()

COS()

Cosine of the argument

Syntax

      COS( nRadiant ) -> nCosine

Arguments

<nRadiant> an angle size given in radiants

Returns

<nCosine> the cosine of <nRadiant>

Description

The function COS() calculates the cosine of an angle whose size is given in radiants (full angle equals 2*Pi – see DTOR() for angle size given in degress). A common geometric interpretation of the COS() function is the ankathede-hypotenuse-ratio of a right-angled triangle.

Examples

      ? cos( 0.0 ) // --> 1.0
      ? cos( 1.0 ) // --> 0.5403...

Tests

      cos( 0.0) == 1.0
      cos( PI() / 4 ) == sqrt( 1 / 2 )
      cos( PI() / 2 ) == 0.0
      cos( PI() ) == -1.0

Compliance

COS() is compatible with CT3’s COS().

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), TAN(), COT(), ASIN(), ACOS(), ATAN(), ATN2(), SINH(), COSH(), TANH(), RTOD(), DTOR(), PI()

ATN2()

ATN2()

Arcus tangent a sine and a cosine argument

Syntax

      ATN2( nSine, nCosine ) -> nRadiant

Arguments

<nSine> the sine of an angle <nCosine> the cosine of an angle

Returns

<nRadiant> the angle whose tangent is <nSine>/<nCosine>

Description

The function ATN2() is an alternate function for calculating the arcus tangent, atn2(x, y) = atan(x/y). It takes two arguments, the sine and the cosine of the angle that should be calculated. Thus, in contrast to the ATAN() function, ATN2() can distinguish whether the sine or the cosine has a negative sign (or both being positive or negative), so that the return value can be between -PI() and PI() and covers the full angle. The return value is given in radiants (full angle equals 2*Pi – see DTOR() if you need to convert it into degress).

Examples

      ? atn2( 0.0, 1.0 ) // --> 0.0
      ? atn2( sqrt( 1 / 2 ), sqrt( 1 / 2 ) ) // --> PI() / 4

Tests

      atn2( 0.0, 1.0 ) == 0.0
      atn2( sqrt( 1 / 2 ), sqrt( 1 / 2 ) ) == PI() / 4
      atn2( -sqrt( 1 / 2 ), -sqrt( 1 / 2 ) ) == -3 / 4 * PI()  // atan() would return PI() / 4 !

Compliance

ATN2() is compatible with CT3’s ATN2().

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), COS(), TAN(), COT(), ASIN(), ACOS(), ATAN(), SINH(), COSH(), TANH(), RTOD(), DTOR(), PI()

ATAN()

ATAN()

Arcus tangent of the argument

Syntax

      ACOS( nTangent ) -> nRadiant

Arguments

<nTangent> the tangent of an angle

Returns

<nRadiant> the angle whose tangent is <nTangent>

Description

The function ATAN() is the inverse function of TAN(). It takes a tangent value and returns the smallest(!) angle whose tangent equals to the argument. The return value is given in radiants between -PI()/2 and PI()/2 (full angle equals 2*Pi – see DTOR() if you need to convert it into degress).

Examples

      ? atan( 0.0 ) // --> 0.0
      ? atan( 0.5 ) // --> 0.4636...

Tests

      atan( 0.0 ) == 0.0
      atan( 1.0 ) == PI() / 4
      atan( 0.0 ) == 0.0 // and not PI(), although tan( PI() ) == 0.0 !

Compliance

ATAN() is compatible with CT3’s ATAN().

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), COS(), TAN(), COT(), ASIN(), ACOS(), ATAN(), SINH(), COSH(), TANH(), RTOD(), DTOR(), PI()

ASIN()

ASIN()

Arcus sine of the argument

Syntax

      ASIN( nSine ) -> nRadiant

Arguments

<nSine> the sine of an angle

Returns

<nRadiant> the angle whose sine is <nSine>

Description

The function ASIN() is the inverse function of SIN(). It takes a sine value and returns the smallest(!) angle whose sine equals to the argument. The return value is given in radiants (full angle equals 2*Pi – see DTOR() if you need to convert it into degress). Note, that <nSine> must be between -1 and 1 and that <nRadiant> is always between -PI()/2 and PI()/2.

Examples

      ? asin( 0.0 ) // --> 0.0
      ? asin( 0.5 ) // --> 0.5235...

Tests

      asin( 0.0 ) == 0.0
      asin( sqrt( 1 / 2 ) ) == PI() / 4
      asin( 1.0 ) == PI() / 2
      asin( 0.0 ) == 0.0  // and not PI(), since the smallest angle is returned !

Compliance

ASIN() is compatible with CT3’s ASIN().

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), COS(), TAN(), COT(), ACOS(), ATAN(), ATN2(), SINH(), COSH(), TANH(), RTOD(), DTOR(), PI()

ACOS()

ACOS()

Arcus cosine of the argument

Syntax

      ACOS( nCosine ) -> nRadiant

Arguments

<nCosine> the cosine of an angle

Returns

<nRadiant> the angle whose cosine is <nCosine>

Description

The function ACOS() is the inverse function of COS(). It takes a cosine value and returns the smallest(!) angle whose cosine equals to the argument. The return value is given in radiants (full angle equals 2*Pi – see DTOR() if you need to convert it into degress). Note, that <nCosine> must be between -1 and 1 and that <nRadiant> is always between 0 and PI().

Examples

      ? acos( 0.0 ) // --> PI() / 2
      ? acos( 0.5 ) // --> 1.04719...

Tests

      acos( 0.0 ) == PI() / 2
      acos( sqrt( 1 / 2 ) ) == PI() / 4
      acos( 1.0 ) == 0.0
      acos( -1.0 ) == PI()
      acos( 0.0 ) == PI() / 2  // and not -PI()/2, although cos (-PI()/2) == 0.0 !

Compliance

ACOS() is compatible with CT3’s ACOS().

Platforms

All

Files

Source is trig.c, library is libct.

Seealso

SIN(), COS(), TAN(), COT(), ASIN(), ATAN(), ATN2(), SINH(), COSH(), TANH(), RTOD(), DTOR(), PI()