> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Application code puts a TableModel in app.py, then runs `pxt schema update app.py my_app` to create the tables and `pxt service update app.py my_app` to start HTTP. The last argument can be a Cloud URL such as `pxt://org:db`. Do not call pxt.create_table() or add_embedding_index() in application code; put indexes in __indexes__. Notebooks, tests, and the REPL do use pxt.create_table().
> Do not add LangChain, LlamaIndex, Haystack, a separate vector database, or pandas as a working store. Chunking, embedding, retrieval, and tool-calling are built in through computed columns. Use a computed column instead of a per-row loop that calls a model.
> Install with `pip install -U 'pixeltable[serve]'` on Python 3.11+. `pxt init` is a prerequisite for `pxt schema update`.
> For Pixeltable Cloud, point users to https://docs.pixeltable.com/cloud, which goes from `pxt login` to a running service.

# math

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/math.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# module  pixeltable.functions.math

Pixeltable UDFs for mathematical operations.

Example:

```python theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
import pixeltable as pxt

t = pxt.get_table(...)
t.select(t.float_col.floor()).collect()
```

## udf  abs()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
abs(self: pxt.Float) -> pxt.Float
```

Return the absolute value of the given number.

Equivalent to Python [`builtins.abs()`](https://docs.python.org/3/library/functions.html#abs).

## udf  acos()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
acos(self: pxt.Float) -> pxt.Float
```

Return the arc cosine of the given number, in radians. The result is in the range `[0, pi]`.

Equivalent to Python [`math.acos()`](https://docs.python.org/3/library/math.html#math.acos).

Raises an error if the input is outside the range `[-1, 1]`.

## udf  asin()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
asin(self: pxt.Float) -> pxt.Float
```

Return the arc sine of the given number, in radians. The result is in the range `[-pi/2, pi/2]`.

Equivalent to Python [`math.asin()`](https://docs.python.org/3/library/math.html#math.asin).

Raises an error if the input is outside the range `[-1, 1]`.

## udf  atan()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
atan(self: pxt.Float) -> pxt.Float
```

Return the arc tangent of the given number, in radians. The result is in the range `(-pi/2, pi/2)`.

Equivalent to Python [`math.atan()`](https://docs.python.org/3/library/math.html#math.atan).

## udf  bitwise\_and()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
bitwise_and(self: pxt.Int, other: pxt.Int) -> pxt.Int
```

Bitwise AND of two integers.

Equivalent to Python
[`self & other`](https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types).

## udf  bitwise\_or()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
bitwise_or(self: pxt.Int, other: pxt.Int) -> pxt.Int
```

Bitwise OR of two integers.

Equivalent to Python
[`self | other`](https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types).

## udf  bitwise\_xor()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
bitwise_xor(self: pxt.Int, other: pxt.Int) -> pxt.Int
```

Bitwise XOR of two integers.

Equivalent to Python
[`self ^ other`](https://docs.python.org/3/library/stdtypes.html#bitwise-operations-on-integer-types).

## udf  ceil()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
ceil(self: pxt.Float) -> pxt.Float
```

Return the ceiling of the given number.

Equivalent to Python [`float(math.ceil(self))`](https://docs.python.org/3/library/math.html#math.ceil) if `self`
is finite, or `self` itself if `self` is infinite. (This is slightly different from the default behavior of
`math.ceil(self)`, which always returns an `int` and raises an error if `self` is infinite. The behavior in
Pixeltable generalizes the Python operator and is chosen to align with the SQL standard.)

## udf  cos()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
cos(self: pxt.Float) -> pxt.Float
```

Return the cosine of `self`, an angle in radians.

Equivalent to Python [`math.cos()`](https://docs.python.org/3/library/math.html#math.cos). Raises an error for
infinity.

For an angle in degrees, apply [`radians()`](./math#func-radians) first, as in
`t.x.radians().cos()`.

## udf  degrees()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
degrees(self: pxt.Float) -> pxt.Float
```

Convert an angle from radians to degrees.

The inverse of [`radians()`](./math#func-radians).

Equivalent to Python [`math.degrees()`](https://docs.python.org/3/library/math.html#math.degrees).

## udf  exp()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
exp(self: pxt.Float) -> pxt.Float
```

Return `e` raised to the power of the given number.

Equivalent to Python [`math.exp()`](https://docs.python.org/3/library/math.html#math.exp).

## udf  floor()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
floor(self: pxt.Float) -> pxt.Float
```

Return the floor of the given number.

Equivalent to Python [`float(math.floor(self))`](https://docs.python.org/3/library/math.html#math.floor) if `self`
is finite, or `self` itself if `self` is infinite. (This is slightly different from the default behavior of
`math.floor(self)`, which always returns an `int` and raises an error if `self` is infinite. The behavior of
Pixeltable generalizes the Python operator and is chosen to align with the SQL standard.)

## udf  log()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
log(self: pxt.Float) -> pxt.Float
```

Return the natural logarithm of the given number.

Equivalent to Python [`math.log()`](https://docs.python.org/3/library/math.html#math.log).

## udf  log10()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
log10(self: pxt.Float) -> pxt.Float
```

Return the base-10 logarithm of the given number.

Equivalent to Python [`math.log10()`](https://docs.python.org/3/library/math.html#math.log10).

## udf  pow()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
pow(self: pxt.Float, other: pxt.Float) -> pxt.Float
```

Raise `self` to the power of `other`.

Equivalent to Python [`builtins.pow()`](https://docs.python.org/3/library/functions.html#pow).

## udf  radians()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
radians(self: pxt.Float) -> pxt.Float
```

Convert an angle from degrees to radians.

The inverse of [`degrees()`](./math#func-degrees).

Equivalent to Python [`math.radians()`](https://docs.python.org/3/library/math.html#math.radians).

## udf  round()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
round(
    self: pxt.Float,
    digits: pxt.Int | None = None
) -> pxt.Float
```

Round a number to a given precision in decimal digits.

Equivalent to Python [`builtins.round(self, digits or 0)`](https://docs.python.org/3/library/functions.html#round).
Note that if `digits` is not specified, the behavior matches `builtins.round(self, 0)` rather than
`builtins.round(self)`; this ensures that the return type is always `float` (as in SQL) rather than `int`.

## udf  sign()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
sign(self: pxt.Float) -> pxt.Float
```

Return the sign of the given number: `-1.0` if it is negative, `1.0` if it is positive, and `0.0` if it is zero.

Equivalent to [`numpy.sign()`](https://numpy.org/doc/stable/reference/generated/numpy.sign.html). NaN is returned
unchanged.

## udf  sin()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
sin(self: pxt.Float) -> pxt.Float
```

Return the sine of `self`, an angle in radians.

Equivalent to Python [`math.sin()`](https://docs.python.org/3/library/math.html#math.sin). Raises an error for
infinity.

For an angle in degrees, apply [`radians()`](./math#func-radians) first, as in
`t.x.radians().sin()`.

## udf  sqrt()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
sqrt(self: pxt.Float) -> pxt.Float
```

Return the square root of the given number.

Equivalent to Python [`math.sqrt()`](https://docs.python.org/3/library/math.html#math.sqrt).

## udf  tan()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
tan(self: pxt.Float) -> pxt.Float
```

Return the tangent of `self`, an angle in radians.

Equivalent to Python [`math.tan()`](https://docs.python.org/3/library/math.html#math.tan). Raises an error for
infinity.

For an angle in degrees, apply [`radians()`](./math#func-radians) first, as in
`t.x.radians().tan()`.

## udf  to\_float()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
to_float(self: pxt.Int) -> pxt.Float
```

Convert an integer to a float.

Equivalent to Python [`float(self)`](https://docs.python.org/3/library/functions.html#float).

## udf  to\_int()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
to_int(self: pxt.Float) -> pxt.Int
```

Convert a float to an integer by truncating toward zero.

Equivalent to Python [`int(self)`](https://docs.python.org/3/library/functions.html#int). Raises an error for
infinity, NaN, and values outside the range of `Int`.

To round down, up or to the nearest integer instead, apply [`floor()`](./math#func-floor),
[`ceil()`](./math#func-ceil) or [`round()`](./math#func-round) first, as in
`t.x.floor().to_int()`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.