machine_learningヘッダファイルパッケージで用いている計算式

1. 数学関数の定義と微分形

関数tanh

(Formula used in machine_learning header file package; 1. Definitions and differential forms of mathematical functions — function tanh)



◆定義(Definition)

\[\begin{equation} f(y)=\tanh(y)=\frac{\exp(y)-\exp(-y)}{\exp(y)+\exp(-y)} \end{equation}\]

◆微分形(Derivative)

\[\begin{eqnarray} f′(y) &=& \left\{\left[\exp(y)+\exp(-y)\right]\left[\exp(y)+\exp(-y)\right]\right. \nonumber \\ & & \left.-\left[\exp(y)-\exp(-y)\right]\left[\exp(y)-\exp(-y)\right]\right\}/ \nonumber \\ & & \left[\exp(y)+\exp(-y)\right]^2 \nonumber \\ &=& \frac{\left[\exp(y)+\exp(-y)\right]^2-\left[\exp(y)-\exp(-y)\right]^2} {\left[\exp(y)+\exp(-y)\right]^2} \nonumber \\ &=& \frac{\left[\exp(y)^2+2+\exp(-y)^2\right] -\left[\exp(y)^2-2+\exp(-y)^2\right]} {\left[\exp(y)+\exp(-y)\right]^2} \nonumber \\ &=& \frac{4}{\left[\exp(y)+\exp(-y)\right]^2} \nonumber \\ &=& \frac{4}{\exp(2y)+2+\exp(-2y)} \end{eqnarray}\]