Hyperbolic Tangent in LaTeX (\tanh)

tanh⁡\tanh
LaTeX command
\tanh
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Hyperbolic tangent, sinh over cosh, with outputs between -1 and 1.

Neural networks use \tanh as an activation function, often compared with the logistic sigmoid through \tanh x = 2\sigma(2x) - 1. Its derivative is 1 - \tanh^2 x, which keeps backpropagation formulas compact. In physics it appears in mean-field magnetization, m = \tanh(\beta J z m), and in relativistic velocity addition. The output range (-1, 1) makes it handy for squashing unbounded quantities. Its inverse \operatorname{artanh} must be written by hand or declared, as LaTeX has no built-in command for it.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

ddxtanh⁡x=1−tanh⁡2x\frac{d}{dx} \tanh x = 1 - \tanh^2 x
\documentclass{article}
\begin{document}
Hyperbolic Tangent: $\tanh$

\[ \frac{d}{dx} \tanh x = 1 - \tanh^2 x \]
\end{document}

Related symbols

All Trigonometri →

Frequently asked questions

How do I write Hyperbolic Tangent in LaTeX?
Type \tanh in math mode, for example $\frac{d}{dx} \tanh x = 1 - \tanh^2 x$. It works in plain LaTeX without loading any package.
Which package do I need for \tanh?
None. \tanh is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \tanh in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\tanh$ in running text.
Math poweredTulis LaTeX menggunakan AI

Editor LaTeX AI Terbaik, Alternatif Overleaf

Octree membantu penyelidik dari 15+ universiti menulis kertas penyelidikan dengan lebih cepat menggunakan AI

  • Jana diagram TikZ yang cantik menggunakan AI
  • Muat naik imej dan tukar ke LaTeX dengan lancar
  • Dapatkan bantuan segera untuk menulis dan memformat kertas penyelidikan