# Solution to non-algebraic equation with parameters

I have to solve the following equation a Tanh[z-b] = z, with a and b parameters and z the unknown.

With a and b known I can use FindRoot. But letting a and b as unknown parameters, I don't know how to solve these type of equations.

• The equation has no analytic solution. Only numerics work here... (unless you want some asymptotic solution for, say, very small a or something like that) – AccidentalFourierTransform Jul 3 at 23:32
• Thank you very much for you answers. I was searching for parametric solutions like z =f(a,b), maybe just for some regimes like small a like AccidentalFourierTransform suggested, if nothing else could be done. – Umberto Maria Tomasini Jul 4 at 7:17
• Your equation has a solution in terms of a generalized Lambert function $z=b+W(a-b;-a-b;1)$. See arxiv.org/pdf/1505.01555 – yarchik Jul 4 at 7:22

The equation is a typical example of a transcendental equation and, as such, it has no analytic solution for symbolic $$a,b$$. That being said, it does admit an asymptotic expansion for small $$a$$ (or large $$b$$), which converges rapidly enough: $$z_\star=\tanh(b) \sum_{i=1}^\infty P_i(\operatorname{sech}(b)) a^i$$ where the polynomials $$P_i$$ are given by \begin{aligned} P_1(x)&=-1\\ P_2(x)&=-x^2\\ P_3(x)&=x^2 - 2 x^4\\ &\cdots \end{aligned}

P[x_] := -1;
P[x_] := -x^2;
P[x_] := x^2 - 2 x^4;
P[x_] := -((2 x^2)/3) + (14 x^4)/3 - 5 x^6;
P[x_] := x^2/3 - (19 x^4)/3 + 19 x^6 - 14 x^8;
P[x_] := -((2 x^2)/15) + (94 x^4)/15 - (199 x^6)/5 + (224 x^8)/3 - 42 x^10;
P[x_] := 1/45 x^2 (2 - 222 x^2 + 2673 x^4 - 9608 x^6 + 13050 x^8 - 5940 x^10);
P[x_] := 1/315 x^2 (-4 + x^2 (1020 - 11 x^2 (1998 + x^2 (-12272 + 945 x^2 (32 - 34 x^2 + 13 x^4)))));
P[x_] := 1/315 (x^2 - 575 x^4 + 21417 x^6 - 211423 x^8 + 841685 x^10 - 1567335 x^12 + 1366365 x^14 - 450450 x^16);

a Tanh[z - b] == z /. z -> Tanh[b] Sum[P[i][Sech[b]] a^i, {i, 1, 9}] + O[a]^10 // Simplify


--

For example, if we take $$a=1/\pi$$ and $$b=e$$, then the numerical solution is $$z_\star=-0.316842\dots$$, to be compared with the four first truncations of the asymptotic solution: $$\color{red}{-0.31}5550\\ \color{red}{-0.31}7284\\ \color{red}{-0.316}751\\ \color{red}{-0.3168}54\\$$

--

FWIW, it appears that \begin{aligned} P_j(x)&=-\frac{2^{2j-2} \left(\frac{1}{2}\right)_{j-1} }{j!}x^{2 j-2}\\ &+\frac{2^{2 j-5} (j-2) (5 j-6) \left(\frac{3}{2}\right)_{j-3} }{3 j!}x^{2 j-4}\\ &-\frac{2^{2 j-9} (j-3) \left(125 j^3-783 j^2+1552 j-960\right) \left(\frac{5}{2}\right)_{j-5} }{15 j!}x^{2 j-6}+\cdots \end{aligned} where $$(\alpha)_\beta$$ denotes the Pochhammer function. It would be interesting to study whether one can find the general form of $$P_j$$ and, perhaps, resum the series.

If you know the parameterranges, ContourPlot3D easily shows possible solutions

ContourPlot3D[a Tanh[z - b] == z, {a, 0, 1}, {b, 0, 5}, {z, -1, 0},AxesLabel -> {a, b, z}] numerical solution

solN[a_?NumericQ, b_?NumericQ] :=z /. NSolve[{a Tanh[z - b] == z, -5 < z < 5}, z][]  (*needs a z-range*)
solN[1/Pi, E]
(* -0.316842 *)


or

sol[a_?NumericQ, b_?NumericQ] :=z /. NMinimize[{1, a Tanh[z - b] == z}, z][]
sol[1/Pi, E]
(* -0.316842 *)