Below is the routine I am using to sort of represent the numerically-inverted function $TP$. Basically I am finding a necessary interpolating polynomial $TPint$ that fits with the data points given by $TPtab$, so that I can represent $TP$ as $TPint$ and use in my other calculations. I just wonder, is this by far the best and proper way to find a polynomial that fits my data points to properly represent my numerically-inverted function? The output looks like a gross. Is there other routine wherein the output is compact and yet the accuracy of the function will not be compromised?

Thank you.

b = 1;
q = -1;
rat = 10^-30;

Why not use NDSolveValue to compute an interpolating function of the inverse? Basically, given $y = f(x)$ we want to find $x = f^{-1}(y)$. To do this differentiate $$y = f(x(y))$$ with respect to $y$ to obtain $$1 = f'(x(y)) x'(y)$$

Hence, the ODE to be solved is: $$x'(y) = 1/f'(x(y))$$

and the following NDSolveValue call should produce your desired result:

if = NDSolveValue[
    {x'[y] == 1/Derivative[1,0,0][rho][x[y], b, q], x[1] == Sqrt[2]}, 
    {y, 0, 1}

(where I used rho[Sqrt[2], b, q] == 1)


GraphicsRow[{Plot[if[ρ], {ρ, 0, 1}], Plot[TPint, {ρ, 0, 1}]}]

enter image description here

  • That's fine also. But my problem is that further in my calculations, i am to use inverse function which is an interpolating function. So how would I able to execute algebraic calculations involving an interpolating function? That's basically my problem, that's why i need to find for an interpolating polynomial to best represent my inverse function. – user583893 Nov 9 at 0:26
  • Notice that the output that TPint gives is a polynomial of certain degree. Is there other way to obtain a reasonable fit with corresponding polynomial to the inverse function? – user583893 Nov 9 at 0:36
  • @user583893 What calculations are you doing that need a polynomial approximation to the inverse? Perhaps there's a way to modify those calculations to work with an interpolation function instead. Also, note that approximations using InterpolatingPolynomial can be very bad, see the Possible issues section in the documentation for InterpolatingPolynomial. – Carl Woll Nov 9 at 0:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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