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 علم المثلثات →

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 poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث