I am interested in the function

$$ y(x) := \left( x +\frac{3\pi}{2} \right) \sin(x) + \cos(x). $$

Over the range $ x \in \left[ -\frac{\pi}{2} ,\frac{\pi}{2} \right]$, this function grows monotonically from $-\pi$ to $2\pi$, as illustrated in this WolframAlpha plot:

enter image description here

Hence, clearly its inverse exists and is well-behaved. I am wondering, however, whether its inverse can be written in terms of known transcendental functions, i.e. whether there is some 'nice' expression $x(y)$.


Let me first define a rescaled function $\tilde y(x) \equiv \frac{2}{3\pi} y(x) - \frac{1}{3}$, just so that the domain $[-\pi/2,\pi/2]$ maps to the range $[-1,1]$. For completeness:

$$ \boxed{ \tilde y(x) = \left( \frac{2x}{3\pi} + 1 \right) \sin(x) + \frac{2}{3\pi} \cos(x) - \frac{1}{3} }. $$

It seems that the inverse is well-approximated by the following function:

$$ \boxed{ x_\textrm{guess}(\tilde y) = \frac{\pi}{2} + \left( \alpha + \beta \tilde y \right) \arccos(\tilde y) + \frac{\gamma}{\pi} \left(\arccos(\tilde y) \right)^2 }. $$

More precisely, if I try to fit this function, I obtain

$$ \begin{array}{ccc} \alpha_\textrm{fit} &= & -0.817 \pm 0.002 \\ \beta_\textrm{fit} &= & -0.032 \pm 0.002 \\ \gamma_\textrm{fit} &= & -0.215 \pm 0.004 \end{array}$$

The fact that this is close to the true inverse is demonstrated in the following plot:

enter image description here

The black curve is $x(\tilde y)$ (this is a numerical result and can be taken to be exact for our practical purposes), and the red dashed curve is $x_\textrm{guess}(\tilde y)$ with the above fitted values of $\alpha$, $\beta$ and $\gamma$.

Do note that the above guess is not the true/complete inverse, since there are still a finite difference between the two curves. The following plot shows $x(\tilde y) - x_\textrm{guess}(\tilde y)$:

enter image description here

The above suggests that it is not crazy to think that there might exist a closed form for $x(\tilde y)$ in terms of known transcendental functions. In case anyone has an idea of what extra term would be sensible to add to my Ansatz inverse $x_\textrm{guess}(\tilde y)$, do let me know. It would be very entertaining if we could make the second plot (i.e. the error plot) zero (within machine precision).

  • $\begingroup$ Well done ! $\to +1$ Concerning your last sentence, don't dream too much ! Cheers $\endgroup$ – Claude Leibovici Feb 6 at 16:37

Nice expression, I do not know.

However, the function is quite well represented using Taylor expansion built at $x=0$. This write $$y=\sum_{n=0}^\infty \frac{3 \pi \sin \left(\frac{\pi n}{2}\right)-2 (n-1) \cos \left(\frac{\pi n}{2}\right)}{2\,n!}\, x^n$$

So, we can use series reversion to get $$x=\sum_{n=1}^p a_n t^n +O(t^{n+1})\qquad \text{where} \qquad t=\frac{2 (y-1)}{3 \pi }$$ where the first coefficients are $$a_1=1 \qquad a_2=-\frac{1}{3 \pi }\qquad a_3=\frac{1}{6}+\frac{2}{9 \pi ^2}\qquad a_4=-\frac{5}{27 \pi ^3}-\frac{7}{36 \pi }$$ $$a_5=\frac{3}{40}+\frac{14}{81 \pi ^4}+\frac{2}{9 \pi ^2}\qquad a_6=-\frac{14}{81 \pi ^5}-\frac{7}{27 \pi ^3}-\frac{53}{360 \pi }$$ $$a_7=\frac{5}{112}+\frac{44}{243 \pi ^6}+\frac{25}{81 \pi ^4}+\frac{371}{1620 \pi ^2}$$ $$a_8=-\frac{143}{729 \pi ^7}-\frac{121}{324 \pi ^5}-\frac{143}{432 \pi ^3}-\frac{823}{6720 \pi }$$ The higher coefficients become more and more messy and they will not be reported here.

To check how good or bad is this approximation, give $x$ a values, compute the correspond $y$ and recompute $x$ using the last formula. This would give the following table $$\left( \begin{array}{ccc} x_{given} & y_{calc} & x_{calc} \\ -1.50 & -3.13360 & -1.24997 \\ -1.25 & -2.97043 & -1.16175 \\ -1.00 & -2.58357 & -0.97992 \\ -0.75 & -1.96923 & -0.74766 \\ -0.50 & -1.14194 & -0.49992 \\ -0.25 & -0.13510 & -0.25000 \\ +0.00 & +1.00000 & +0.00000 \\ +0.25 & +2.19663 & +0.25000 \\ +0.50 & +3.37653 & +0.49990 \\ +0.75 & +4.45506 & +0.74733 \\ +1.00 & +5.34711 & +0.97727 \\ +1.25 & +5.97354 & +1.15378 \\ +1.50 & +6.26756 & +1.23905 \end{array} \right)$$ which not bad at least over the range $-1 \leq x \leq 1$.

For sure, we could improve these results building the series expansions centered at $x=-\frac \pi 2$, $x=0$ and $x=\frac \pi 2$ and proceed the same way using the reversed series for $-\frac \pi 2 \leq x \leq -1$, $-1 \leq x \leq 1$ and $1 \leq x \leq \frac \pi 2$.

  • $\begingroup$ Claude, thanks for the post. You inspired me to also try some experimental mathematics. $\endgroup$ – Ruben Verresen Feb 6 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.