There is a subtle numerics issue at work here, and one might complain to technical support about it. For such a function as in the question, InverseFunction[f][x0]
calls FindRoot
to solve f[y] == x0
for the value y0
of the inverse function. It then tests the result to see if y0
is accurate enough to be acceptable. To do this, it calls Chop
on the value of f[y0] - x0
to see if it is zero; that is to say, it will be acceptable if Abs[f[y0] - x0]
is less than 10^-10
.
Now to the numerics. One can expect a rounding error of around x0 * $MachineEpsilon
, which for the problem at hand is:
2123456.12345` * $MachineEpsilon
(* 4.71502*10^-10 *)
One would expect that f[y0] - x0
to evaluate to around this error or less if y0
was the most accurate machine-precision solution to f[y] == x0
.
What happens for the value 2123456.12345`
is that the error is greater than the tolerance 10^-10
used in Chop
:
FindRoot[-2.12345612345`*^6 + 494.246913578` x + x^2/2 + 61070.00289534475` Log[x] == 0, {x, 1.}]
(* {x -> 1404.6931869719137`} *)
(494.246913578` x + x^2/2 + 61070.00289534475` Log[x]) - 2.12345612345`*^6 /. {x -> 1404.6931869719137`}
(* 2.32831*10^-10 *)
For the value 2123456.1234`
that works, it happens that the error is zero:
FindRoot[-2.1234561234`*^6 + 494.246913578` x + x^2/2 + 61070.00289534475` Log[x] == 0, {x, 1.}]
(* {x -> 1404.6931869461725`} *)
(494.246913578` x + x^2/2 + 61070.00289534475` Log[x]) - 2.1234561234`*^6 /. {x -> 1404.6931869461725`}
(* 0. *)
If you raise the precision of the coefficients and input to 16 or more, you will get the desired answer. For instance,
InverseFunction[247.123456789`^2 Log[#1] + 2*247.123456789` #1 + #1^2/2 &][2123456.12345`] /.
x_?Developer`MachineRealQ :> SetPrecision[x, $MachinePrecision]
(* 1404.693186971914 *)