Solving a hyperbolic tangent function for X

356 Views Asked by At

I've attempted to solve this equation on my own, but... four hours later and here I am. My coworker is attempting to make a machine learning program and he needs to find the value of $x$ in this equation:

\begin{equation} R = \tanh( \tanh(a+x)z + \tanh(b+x)y + \tanh(c+x)w ) \end{equation}

Where $-1 < R < 1$.

I'm kind of bashing my head against this struggling to figure out how to isolate $x$. I first tried writing the equation out with the knowledge that:

\begin{equation} \tanh = \frac{e^x - e^{-x}}{e^x + e^{-x}} \end{equation}

Which resulted in this absolute abomination that is no closer to me actually isolating $x$

\begin{equation} R = \frac{\exp{\left(\dfrac{z\cdot e^{2a+2x}-z}{e^{2a+2x}+1} + \dfrac{y\cdot e^{2b+2x}-y}{e^{2b+2x}+1}+\dfrac{w\cdot e^{2c+2x}-w}{e^{2c+2x}+1}\right)} \\- \exp{\left(-\left({\dfrac{z\cdot e^{2a+2x}-z}{e^{2a+2x}+1} + \dfrac{y\cdot e^{2b+2x}-y}{e^{2b+2x}+1}+\dfrac{w\cdot e^{2c+2x}-w}{e^{2c+2x}+1}}\right)\right)}}{\exp{\left(\dfrac{z\cdot e^{2a+2x}-z}{e^{2a+2x}+1} + \dfrac{y\cdot e^{2b+2x}-y}{e^{2b+2x}+1}+\dfrac{w\cdot e^{2c+2x}-w}{e^{2c+2x}+1}\right)}\\ + \exp{\left(-\left({\dfrac{z\cdot e^{2a+2x}-z}{e^{2a+2x}+1} + \dfrac{y\cdot e^{2b+2x}-y}{e^{2b+2x}+1}+\dfrac{w\cdot e^{2c+2x}-w}{e^{2c+2x}+1}}\right)\right)}} \end{equation}

And I've sort of just been stuck switching this equation into different forms but never actually getting closer to solving for $x$. Another messy iteration:

\begin{equation} \frac{z\cdot e^{2a+2x}-z}{e^{2a+2x}+1} + \frac{y\cdot e^{2b+2x}-y}{e^{2b+2x}+1} + \frac{w\cdot e^{2c+2x}-w}{e^{2c+2x}+1} = \frac{1}{2}\log\left(\frac{-R-1}{R-1}\right) \end{equation}

Any ideas? I've never really dealt with hyperbolic tangents before, so I might be missing something obvious.

1

There are 1 best solutions below

0
On

That's weird. Why are you taking the $\tanh$ of the sum of $\tanh$s?

Anyway, an obvious first step is to rewrite it as $\text{atanh}(R) = \tanh(a+x)z + \tanh(b+x)y + \tanh(c+x)w $.

There isn't any formula for $\tanh(u)+\tanh(v) $, so you will have to solve this numerically.

Since $\tanh'(x) = 1-\tanh^2(x) $, Newton's method would probably work nicely.

Good luck.