# Plotting the inverse function of a complicated function

So I have a function

F[x_] = Assuming[{Element[x, Reals], -1 < x < 1},
Integrate[1/Sqrt[(x^2 - 1)^2 + alpha*x], x]]


I'm now interested in the inverse function :

G[x_]=InverseFunction[F][x]


But I get no answer from Mathematica...

What I'd like to do is to plot the inverse function, I don't manage to do it... And to play with the values of $$\alpha$$ please.

• Normally, I'd say start with a visualization (and if all you're interested in is plotting then you could stop there, too): Block[{alpha = 1/2}, ContourPlot[x == F[y], {x, -4, 4}, {y, -1, 1}]] -- but the results are not encouraging. Jul 31, 2019 at 15:53
• For some values of alpha F[x] is a complex number, so probably plotting Re makes sense. To play with alpha use Manipulate: Manipulate[ContourPlot[ Evaluate[x == Re@(F[y] /. alpha -> a)], {x, -4, 4}, {y, -1,1}], {a, -1, 1}].
– Alx
Jul 31, 2019 at 16:11
• One of the problems is that Integrate does not give a discontinuous antiderivative that cannot be used to evaluate the definite integral. Is that what you want? Jul 31, 2019 at 22:05
• "...plot the inverse function, I don't manage to do it... And to play with the values of $\alpha$ please." - are you perhaps expecting an elliptic function? It might be profitable for you to first convert your elliptic integral to Weierstrass form, whose inversion might be more amenable. Aug 2, 2019 at 7:55
• Right I think it's linked to elliptic functions ! I'll try to do what you're saying (I don't know yet what is a Weierstrass form)
– J.A
Aug 2, 2019 at 8:39

The antiderivative returned by Integrate has some problems. It might be better to numerically integrate, but take care to avoid the singularity where the square-root is zero:

psol = ParametricNDSolveValue[
{x'[y] ==  Sqrt[(x[y]^2 - 1)^2 + alpha*x[y]], x[0] == x0,
WhenEvent[Abs[(x[y]^2 - 1)^2 + alpha*x[y]] < 1*^-6, "StopIntegration"],
WhenEvent[Abs[x[y]] > xmax, "StopIntegration"]
}, x, {y, -3, 3}, {alpha, x0, xmax},
Method -> "ExplicitRungeKutta",
"ExtrapolationHandler" -> {Indeterminate &}];

ListLinePlot[psol[0.5, 0, 5], PlotRange -> All,
InterpolationOrder -> 3]


Update: Relationship to the OP's Integrate[] result

It's clear that the definite integral $$F(\alpha,x;a)=\int_a^x \frac{1}{\sqrt{\left(\xi^2-1\right)^2+\alpha \xi}} \, d\xi$$ will be real-valued as long as the entire interval $$(a,x)$$ lies in the region above Root[1 + alpha #1 - 2 #1^2 + #1^4 &, 1] or the region below Root[1 + alpha #1 - 2 #1^2 + #1^4 &, 2]. It should also be clear that over either region, $$F$$ is monotonic and bounded as a function of $$x$$. A numerical approximation to the optimal bound may be obtained by setting xmax to the numeric equivalent of infinity, \$MaxNumber, in the call to psol above. The bound will be announced in a ParametricNDSolveValue::ndsz error and will depend on the initial condition and alpha. It corresponds to a vertical asymptote in the graph of the inverse function. Similarly the time $$y$$ to reach the point where the square-root is zero is finite, except for $$\alpha = 0$$, when the expression under the radical becomes a perfect square.

Since any two antiderivatives differ by a constant, the corresponding graphs differ by a translation. The graphs of the inverse functions will differ by a horizontal translation. It's easy to translate the psol solution to overlap the one shown in @BobHanlon's answer for alpha = 0.5:

F[alpha_, x_] =  (* Bob Hanlon's definition *)
Assuming[{Element[x, Reals], -1 < x < 1},
Integrate[1/Sqrt[(x^2 - 1)^2 + alpha*x], x] // FullSimplify];

p1 = Plot[psol[0.5, 0, 5][x - Re@F[0.5, 0]], {x, -1, 3.5},
PlotStyle -> {AbsoluteThickness[3], Red}, PlotRange -> All,
PlotLegends -> {"psol"}]

Block[{alpha = 0.5},  (* Bob's plot *)
p2 = ParametricPlot[
{{Re@F[alpha, x], x}, {Im@F[alpha, x], x}, {Abs@F[alpha, x], x}},
{x, -1, 1}, AspectRatio -> 1,
PlotRange -> All, Frame -> True,
FrameLabel -> (Style[#, 12, Bold] & /@ {"F[alpha, x]", "x"}),
PlotLegends -> {Re, Im, Abs}]
]

Show[p1, p2, GridLines -> {None, {0.88}}]


Extras

Here's a demo to play with the values of $$\alpha$$:

Manipulate[
Quiet@ListLinePlot[psol[alpha, 0, 5],
InterpolationOrder -> 3, PlotRange -> {{-3, 3}, {-1.1, 5.1}}],
{{alpha, 0.5}, 0, 1}]


To play in the other region, change the initial condition parameter x0:

Manipulate[
Quiet@ListLinePlot[psol[alpha, -2, 5],
PlotStyle -> {AbsoluteThickness[2], Red}, InterpolationOrder -> 3,
PlotRange -> {{-3, 3}, {-5.1, 0.1}}],
{{alpha, 0.5}, 0, 1}]


Inverse functions can be plotted using ParametricPlot or ParametricPlot3D

Clear["Global*"]

F[alpha_, x_] =
Assuming[{Element[x, Reals], -1 < x < 1},
Integrate[1/Sqrt[(x^2 - 1)^2 + alpha*x], x] // FullSimplify];

Manipulate[
ParametricPlot[{
{Re@F[alpha, x], x},
{Im@F[alpha, x], x},
{Abs@F[alpha, x], x}},
{x, -1, 1},
AspectRatio -> 1,
PlotRange -> All,
Frame -> True,
FrameLabel -> (Style[#, 12, Bold] & /@ {"F[alpha, x]", "x"}),
PlotLegends -> {Re, Im, Abs}] //
Quiet,
{{alpha, 0.5}, 0.005, 1, 0.005, Appearance -> "Labeled"}]
`