Skip to content
fn

tan

→Tensor
tan(input: Tensor)

Implementing kernel

C++ engine symbols that back this Python API.

Element-wise tangent (input in radians).

Computes tan⁡(x)\tan(x). Diverges at odd multiples of π/2\pi/2.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=tan⁡(inputi)\text{out}_i = \tan(\text{input}_i)

Gradient: 1/cos⁡2(x)=1+tan⁡2(x)1 / \cos^{2}(x) = 1 + \tan^{2}(x).

Examples

>>> import lucid
>>> x = lucid.tensor([1.0, 2.0, 3.0])
>>> lucid.tan(x)
Tensor([...])