# Functions

The following functions are available globally.

• ``` abs(_:) ```

Computes the absolute value of a number.

#### Declaration

``func abs(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The absolute value of `x`.

• ``` atan2(_:_:) ```

Computes the arc tangent of two numbers.

The atan2() function is used to convert from rectangular (x,y) to polar (r,theta) coordinates where `theta = atan2(y, x)`.

#### Declaration

``func atan2(_ y: Double, _ x: Double) -> Double``

#### Parameters

y

A number value.

x

A number value.

#### Return Value

The arc tangent of `y/x`, taking into account the signs of both arguments to determine the quadrant.

• ``` ceil(_:) ```

Computes the ceiling (rounding up) of a number.

#### Declaration

``func ceil(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The smallest integer greater than or equal to `x`.

• ``` cos(_:) ```

Computes the cosine of a number.

#### Declaration

``func cos(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The cosine of `x`.

• ``` exp(_:) ```

Computes the base-e exponential of a number.

#### Declaration

``func exp(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

Euler’s number e to raised to the power of `x`.

• ``` floor(_:) ```

Computes the floor (rounding down) of a number.

#### Declaration

``func floor(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The largest integer less than or equal to `x`.

• ``` log(_:) ```

Computes the natural logarithm of a number.

#### Declaration

``func log(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The natural logarithm of `x`.

• ``` pow(_:_:) ```

Computes the power function.

#### Declaration

``func pow(_ x: Double, _ y: Double) -> Double``

#### Parameters

x

A number value used as the base.

y

A number value used as the exponent.

#### Return Value

`x` raised to the power of `y`.

• ``` round(_:) ```

Rounds a number to the closest integer.

#### Declaration

``func round(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The integer closest to `x`, half-way cases round away from zero.

• ``` sin(_:) ```

Computes the sine of a number.

#### Declaration

``func sin(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The sine of `x`.

• ``` sqrt(_:) ```

Computes the square root of a number.

#### Declaration

``func sqrt(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The square root of `x`.

• ``` tan(_:) ```

Computes the tangent of a number.

#### Declaration

``func tan(_ x: Double) -> Double``

#### Parameters

x

A number value.

#### Return Value

The tangent of `x`.