Hyperbolic Tangent in LaTeX (\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.
\documentclass{article}
\begin{document}
Hyperbolic Tangent: $\tanh$
\[ \frac{d}{dx} \tanh x = 1 - \tanh^2 x \]
\end{document}Related symbols
- Inverse Hyperbolic Sine
\text{arcsinh} - Hyperbolic Cosine
\cosh - Pi
\pi - Hyperbolic Sine
\sinh - Degree symbol
^{\circ} - Inverse Tangent
\tan^{-1}
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.
Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf
Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI
- Gumawa ng magagandang TikZ diagrams gamit ang AI
- Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
- Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers