Skip to content
fn

cosh

→Tensor
cosh(input: Tensor)

Implementing kernel

C++ engine symbols that back this Python API.

Element-wise hyperbolic cosine.

Computes cosh⁡(x)=(ex+e−x)/2\cosh(x) = (e^{x} + e^{-x}) / 2 for each entry. Always ≥1\ge 1.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=cosh⁡(xi)=exi+e−xi2\text{out}_i = \cosh(x_i) = \frac{e^{x_i} + e^{-x_i}}{2}

Gradient: sinh⁡(x)\sinh(x).

Examples

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