fn

divide

Tensor
divide(a: Tensor, b: Tensor | Scalar)
source

Element-wise true division.

Verbose alias of the / operator. Always performs floating-point division — integer operands are promoted to a floating dtype before the division so that the result preserves fractional parts.

Parameters

aTensor
Numerator.
bTensor | Scalar
Denominator.

Returns

Tensor

Element-wise quotient of the broadcast shape of a and b, in a floating-point dtype.

Notes

Mathematical definition:

outi=aibi\text{out}_i = \frac{a_i}{b_i}

Division by zero produces ±\pm\infty (or NaN for 0/0) rather than raising. Gradients are /a=1/b\partial / \partial a = 1/b and /b=a/b2\partial / \partial b = -a / b^{2}.

Examples

>>> import lucid
>>> a = lucid.tensor([6.0, 9.0])
>>> lucid.divide(a, 3.0)
Tensor([2., 3.])