# std.math

Extended math: powers, logarithms, trigonometry, and float utilities.

```tea
use math from "std.math"
```

Examples may be fragments requiring the module import or additional setup.

## std.math.pi

```tea
pub def pi() -> Float
```

Return pi.

## std.math.e

```tea
pub def e() -> Float
```

Return Euler's number e.

## std.math.pow

```tea
pub def pow(base: Float, exponent: Float) -> Float
```

Raise base to the given power.

```tea
use math from "std.math"

@println(math.pow(2.0, 10.0)) # 1024
```

## std.math.exp

```tea
pub def exp(value: Float) -> Float
```

Return e raised to the given power.

## std.math.log

```tea
pub def log(value: Float) -> Float
```

Return the natural logarithm.

## std.math.log2

```tea
pub def log2(value: Float) -> Float
```

Return the base-2 logarithm.

```tea
use math from "std.math"

@println(math.log2(1024.0)) # 10
```

## std.math.log10

```tea
pub def log10(value: Float) -> Float
```

Return the base-10 logarithm.

## std.math.sin

```tea
pub def sin(value: Float) -> Float
```

Return the sine of an angle in radians.

```tea
use math from "std.math"

const radians = 90.0 * math.pi() / 180.0
@println(math.sin(radians)) # 1
```

## std.math.cos

```tea
pub def cos(value: Float) -> Float
```

Return the cosine of an angle in radians.

## std.math.tan

```tea
pub def tan(value: Float) -> Float
```

Return the tangent of an angle in radians.

## std.math.asin

```tea
pub def asin(value: Float) -> Float
```

Return the arcsine in radians.

## std.math.acos

```tea
pub def acos(value: Float) -> Float
```

Return the arccosine in radians.

## std.math.atan

```tea
pub def atan(value: Float) -> Float
```

Return the arctangent in radians.

## std.math.atan2

```tea
pub def atan2(y: Float, x: Float) -> Float
```

Return the four-quadrant arctangent of y/x in radians.

## std.math.hypot

```tea
pub def hypot(x: Float, y: Float) -> Float
```

Return sqrt(x^2 + y^2) without intermediate overflow.

```tea
use math from "std.math"

@println(math.hypot(3.0, 4.0)) # 5
```

## std.math.trunc

```tea
pub def trunc(value: Float) -> Int
```

Truncate toward zero, returning an Int.

## std.math.sign

```tea
pub def sign(value: Float) -> Int
```

Return -1, 0, or 1 according to the sign of the value.

## std.math.clamp

```tea
pub def clamp(value: Float, low: Float, high: Float) -> Float
```

Clamp a value into the inclusive range [low, high].

```tea
use math from "std.math"

@println(math.clamp(1.5, 0.0, 1.0)) # 1
```

## std.math.floor

```tea
pub def floor(value: Float) -> Int
```

Round down to the nearest integer (same as the @floor builtin).

## std.math.ceil

```tea
pub def ceil(value: Float) -> Int
```

Round up to the nearest integer (same as the @ceil builtin).

## std.math.round

```tea
pub def round(value: Float) -> Int
```

Round to the nearest integer (same as the @round builtin).

```tea
use math from "std.math"

@println(math.round(3.6)) # 4
@println(math.trunc(3.6)) # 3
```

## std.math.abs

```tea
pub def abs(value: Float) -> Float
```

Return the absolute value (same as the @abs builtin).

## std.math.sqrt

```tea
pub def sqrt(value: Float) -> Float
```

Return the square root (same as the @sqrt builtin).

## std.math.min

```tea
pub def min(a: Float, b: Float) -> Float
```

Return the smaller of two values (same as the @min builtin).

## std.math.max

```tea
pub def max(a: Float, b: Float) -> Float
```

Return the larger of two values (same as the @max builtin).
