0
$\begingroup$

We can define an InverseFunction even when the inverse can't be expressed in closed form.

f[x_]:=1.1*x+Sin[x];
fInverse=InverseFunction[1.1*#+Sin[#]&];
Plot[{f[x],fInverse[x],x},{x,0,14},
   PlotStyle->{Blue,Brown,{Gray,Dashed}},
   PlotRange->{{0,14},{0,14}},AspectRatio->1
]

plot We can also compute the first derivative of fInverse.

fInverse'[3.46]
(* 9.91112 *)

However, trying to compute the second derivative doesn't work.

fInverse''[3.46]
(* -4.15922 (9.91112+(0& (InverseFunction')[1.1 #1+Sin[#1]&])[3.46]) *)

Is it possible to compute higher derivatives using an approach similar to computing the first derivative? I am using Version 12.0.0. Are any later versions able to compute higher derivatives of such an InverseFunction?

$\endgroup$
5
  • $\begingroup$ You are interested in the fully numerical approach, right? $\endgroup$
    – yarchik
    Commented Nov 5, 2021 at 15:53
  • 2
    $\begingroup$ On V12.3 it's working for me. fInverse''[3.46] gives -41.2225. $\endgroup$ Commented Nov 5, 2021 at 15:53
  • $\begingroup$ It is interesting that the documentation for InverseFunction gives an example of InverseFunction[(a # + b)/(c # + d) &] which works, your example of InverseFunction[1.1*#+Sin[#]&] does not. This behavior should be documented. The answer by Bob Hanlon shows that using InverseFunction[f] works. I don't understand why the difference. $\endgroup$
    – Somos
    Commented Nov 5, 2021 at 17:04
  • $\begingroup$ The following will run increasingly faster as the order of the derivative grows for the 4th order and up: Experimental`OptimizeExpression[InverseFunction[g]''''[x]] /. g -> f /. x -> 3.46 // First (Assumes g and x are undefined.) $\endgroup$
    – Michael E2
    Commented Nov 7, 2021 at 2:28
  • $\begingroup$ I presume you've already seen this article? $\endgroup$ Commented Dec 9, 2021 at 20:55

2 Answers 2

3
$\begingroup$
f[x_] := 1.1*x + Sin[x];

fInverse = InverseFunction[f];

Through[{fInverse, fInverse', fInverse''}[x]]

enter image description here

% /. x -> 3.46

(* {3.18395, 9.91112, -41.2225} *)

Plot[{fInverse[x], fInverse'[x], fInverse''[x]}, {x, 0, 6},
 PlotLegends -> Placed["Expressions", {.25, .75}]]

enter image description here

EDIT: In my version the longer form also works

Clear[fInverse]

fInverse = InverseFunction[1.1*# + Sin[#] &];

{fInverse[x], fInverse'[x], fInverse''[x]}

(* {InverseFunction[1.1 #1 + Sin[#1] &][x], 
 1/(1.1 + Cos[InverseFunction[1.1 #1 + Sin[#1] &][x]]), 
 Sin[InverseFunction[1.1 #1 + Sin[#1] &][x]]/(1.1 + 
    Cos[InverseFunction[1.1 #1 + Sin[#1] &][x]])^3} *)

% /. x -> 3.46

(* {3.18395, 9.91112, -41.2225} *)
$\endgroup$
1
  • $\begingroup$ At least with version 12.0.0 we need to use InverseFunction[f] rather than InverseFunction[1.1*#+Sin[#]&]. $\endgroup$
    – Ted Ersek
    Commented Nov 5, 2021 at 17:51
0
$\begingroup$

If you are interested in a numerical approach, it is the classical case for the use of NDSolve or NDSolveValue

f[x_] := 1.1*x + Sin[x]
gg = NDSolveValue[{g'[y] == 1/f'[g[y]], g[0] == 0}, g, {y, 0, 10}]
Plot[{gg[x], gg'[x], gg''[x]}, {x, 0, 10}]

enter image description here

The verification can be done as follows

Plot[{f[gg[x]]}, {x, 0, 10}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Something seems to be wrong here: Plot[{f[gg[x]],x }, {x, 0, 10}] should give Identity I think! $\endgroup$ Commented Nov 5, 2021 at 16:29
  • $\begingroup$ @UlrichNeumann Done, the post is updated. Thank you for checking everything carefully! $\endgroup$
    – yarchik
    Commented Nov 5, 2021 at 16:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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