# [✓] Why InverseFunction gives different types of results?

Posted 1 year ago
1016 Views
|
|
1 Total Likes
|
 Hi!Could anybody tell me why evaluations of this two expressions in Mathematica 9 In[1] := InverseFunction[247.123456789^2 Log[#1] + 2*247.123456789 #1 + #1^2/2 &][2123456.12345] In[2] := InverseFunction[247.123456789^2 Log[#1] + 2*247.123456789 #1 + #1^2/ 2 &][2123456.1234] lead to different type of answers: Out[1] := InverseFunction[247.123^2 Log[#1] + 2 247.123 #1 + #1^2/2 &][2.12346*10^6] Out[2] := 1404.69 The only difference is the number of digits after the point in the argument. How can I force M9 to show me a numerical result in the second case? //N does not help.Thank you in advance.
 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_?DeveloperMachineRealQ :> SetPrecision[x, \$MachinePrecision] (* 1404.693186971914 *) `