I have a polynomial constructed with InterpolatingPolynomial. It is not a one-to-one function but I want to have its inverse on some range where it is monotonously increasing.

According to documentation and this answer I should use ConditionalExpression. But it seems that InverseFunction[ConditionalExpression[f, condition_for_my_range]] still tries to find inverse for a whole function.

Below is my code:

f = InterpolatingPolynomial[{{7, 0}, {1, 0}, {4, 0}, {2.5, 0}, 8, 10}, #] &;
Plot[{f[x],3}, {x, 1,5}, AxesOrigin->{1,0}]
finv = InverseFunction[(ConditionalExpression[f[#],4.1<#<4.9]) &];

How it looks like in Wolfram|One

I get warning InverseFunction: Inverse functions are being used. Values may be lost for multivalued inverse and output 2.56775. I've expected something near 4.4.

It seems that Mathematica finds the second root of f(x)=3, not the fourth, despite the fact I've set the range for roots explicitly. The same problem in both in Mathematica Desktop 12.1 and Wolfram|One.

It it a bug, or a mistake in my understanding how these things should work?

  • $\begingroup$ As a workaround, use FindRoot: finv := Module[{x}, x /. FindRoot[f[x] == #, {x, 4.5}] &] $\endgroup$
    – Bob Hanlon
    Apr 11 '20 at 14:12
  • $\begingroup$ @Bob thanks, looks like a good workaround :) But it's strange that InverseFunction can't solve quite a simple problem $\endgroup$
    – sckol
    Apr 11 '20 at 14:19

Your Answer

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

Browse other questions tagged or ask your own question.