# Module: GeographicLib/Math

Some useful mathematical constants and functions (mainly for internal use).

Source:

### Members

#### (static, constant) degree :number

The factor to convert degrees to radians.

• number
Source:

#### (static, constant) digits :number

The number of digits of precision in floating-point numbers.

• number
Source:

#### (static, constant) epsilon :number

The machine epsilon.

• number
Source:

### Methods

#### (static) AngDiff(x, y) → {object}

The exact difference of two angles reduced to (−180°, 180°]

##### Parameters:
Name Type Description
`x` number

the first angle in degrees.

`y` number

the second angle in degrees.

Source:
##### Returns:

diff the exact difference, y − x.

This computes z = y − x exactly, reduced to (−180°, 180°]; and then sets diff.s = d = round(z) and diff.t = e = z − round(z). If d = −180, then e > 0; If d = 180, then e ≤ 0.

Type
object

#### (static) AngNormalize(x) → {number}

Normalize an angle.

##### Parameters:
Name Type Description
`x` number

the angle in degrees.

Source:
##### Returns:

the angle reduced to the range (−180°, 180°].

Type
number

#### (static) AngRound(x) → {number}

Coarsen a value close to zero.

##### Parameters:
Name Type Description
`x` number
Source:
##### Returns:

the coarsened value.

Type
number

#### (static) atan2d(y, x)

Evaluate the atan2 function with the result in degrees

##### Parameters:
Name Type Description
`y` number
`x` number
Source:
##### Returns:

atan2(y, x) in degrees, in the range (−180° 180°].

#### (static) atanh(x) → {number}

Inverse hyperbolic tangent.

##### Parameters:
Name Type Description
`x` number

the argument.

Source:

tanh−1 x.

Type
number

#### (static) cbrt(x) → {number}

Cube root function.

##### Parameters:
Name Type Description
`x` number

the argument.

Source:
##### Returns:

the real cube root.

Type
number

#### (static) copysign(x, y) → {number}

Copy the sign.

##### Parameters:
Name Type Description
`x` number

gives the magitude of the result.

`y` number

gives the sign of the result.

Source:
##### Returns:

value with the magnitude of x and with the sign of y.

Type
number

#### (static) hypot(x, y) → {number}

The hypotenuse function.

##### Parameters:
Name Type Description
`x` number

the first side.

`y` number

the second side.

Source:

the hypotenuse.

Type
number

#### (static) LatFix(x) → {number}

Normalize a latitude.

##### Parameters:
Name Type Description
`x` number

the angle in degrees.

Source:
##### Returns:

x if it is in the range [−90°, 90°], otherwise return NaN.

Type
number

#### (static) log1p(x) → {number}

The log1p function.

##### Parameters:
Name Type Description
`x` number

the argument.

Source:

log(1 + x).

Type
number

#### (static) polyval(N, p, x) → {number}

Evaluate a polynomial.

##### Parameters:
Name Type Description
`N` integer

the order of the polynomial.

`p` array

the coefficient array (of size N + 1) (leading order coefficient first)

`x` number

the variable.

Source:
##### Returns:

the value of the polynomial.

Type
number

#### (static) sincosd(x) → {object}

Evaluate the sine and cosine function with the argument in degrees

##### Parameters:
Name Type Description
`x` number

in degrees.

Source:
##### Returns:

r with r.s = sin(x) and r.c = cos(x).

Type
object

#### (static) sq(x) → {number}

Square a number.

##### Parameters:
Name Type Description
`x` number

the number.

Source:

the square.

Type
number

#### (static) sum(u, v) → {object}

An error-free sum.

##### Parameters:
Name Type Description
`u` number
`v` number
Source:
##### Returns:

sum with sum.s = round(u + v) and sum.t is u + v − round(u + v)

Type
object