← Back to the index

Module std/math.vv

The math module provides standard mathematical functions and constants.

Example:

import math from "std/math.vv"

let s = math.sin(math.pi / 2.0) // 1.0
let r = math.sqrt(16.0)           // 4.0

Table of Contents

Exports

let pi extern "native"

The ratio of the circumference of a circle to its diameter.

Example:

math.pi // 3.141592653589793

let e extern "native"

The base of the natural logarithm.

Example:

math.e // 2.718281828459045

fun sin(x) extern "native"

Returns the sine of the radian argument x.

Example:

let s = math.sin(math.pi / 2.0) // 1.0

fun asin(x) extern "native"

Returns the arcsine, in radians, of x.

Example:

let a = math.asin(1.0) // 1.5707963267948966

fun cos(x) extern "native"

Returns the cosine of the radian argument x.

Example:

let c = math.cos(math.pi) // -1.0

fun acos(x) extern "native"

Returns the arccosine, in radians, of x.

Example:

let a = math.acos(-1.0) // 3.141592653589793

fun tan(x) extern "native"

Returns the tangent of the radian argument x.

Example:

let t = math.tan(0.0) // 0.0

fun atan(x) extern "native"

Returns the arctangent, in radians, of x.

Example:

let a = math.atan(0.0) // 0.0

fun atan2(y, x) extern "native"

Returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value.

Example:

let a = math.atan2(0.0, -1.0) // 3.141592653589793

fun pow(x, y) extern "native"

Returns x strictly raised to the power of y.

Example:

let p = math.pow(2.0, 3.0) // 8.0

fun sqrt(x) extern "native"

Returns the square root of x.

Example:

let s = math.sqrt(16.0) // 4.0