Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I want to invert the following function with respect to $x$:

$$f(x, k)=x+k x^3$$

where typical values for $x$ are between $0$ and $100$ and typical values for $k$ are between $-0.00005$ and $0.00005$. Further, it is known that:

$$k >-\frac{1}{3x^2}$$

therefore, the function should be invertible. The derivatives:

$$\begin{align}\frac{df}{dx}&=1+3kx^2\\ \frac{df}{dk} &= x^3\end{align}$$

are non-negative for all possible values of x and k. So the Function $f$ is monotonically increasing in both dimensions.

I need the function $g(y, k)$ so that $g(f(x, k), k) = x$ for all $x$ and all $k$.


What I have tried: The following function returns correct values for all $k>0$. For negative $k$ it does not work (returns complex numbers).

$$w = \sqrt[3]{\frac{y}{2 k} + \sqrt{\frac{y^2}{4 k^2} + \frac{1}{27 k^3}}}\\ g(y,k) = w - \frac{1}{3 kw}$$

share|improve this question
    
u can try wolfram alpha, for reference. –  Shobhit Jul 21 '13 at 9:41
    
Well, I tried: wolframalpha.com/input/… still uses complex numbers all over the place and does not seem to be valid for positive k. –  DasKrümelmonster Jul 21 '13 at 11:02
    
The inverse function will be an odd function. Its power series might converge relatively quickly, and be reasonably accurate with a manageable number of terms. You appear to using approximate values anyway, is this a correct impression? –  Jyrki Lahtonen Jul 21 '13 at 12:13
    
The function comes from distortion correction. The coefficient k is found by camera calibration and in my program I need to convert image to world coordinates and vice versa. While the transformation is measured (and therefore, cannot be exact) I really need exact roundtrips. (i.e. the g(f(x, k), k) = x must be very accurate) –  DasKrümelmonster Jul 21 '13 at 12:35

1 Answer 1

up vote 1 down vote accepted

Okay, i got it.

Using the second solution from WolframAlpha, and discarding the imaginary part, does the job for negative $k$. As both solutions do not work for $k=0$ I have the following solution:

function [ x ] = im2w( y, Kappa )
    if abs(Kappa) < 1e-10
        x = y / (1 + Kappa *  (y' * y));
    elseif(Kappa > 0)
        direction = y/norm(y);
        w = nthroot(norm(y)/(2*Kappa) + sqrt((y'*y)/(4 * Kappa^2) + 1/(27*Kappa^3)), 3);
        x = direction * (w - 1./(3*Kappa*w));
    elseif(Kappa < 0)
        direction = y/norm(y);
        y = norm(y);
        x_wa2 = (1-1i * sqrt(3))/(2^(2/3) * 3^(1/3) * (9 * Kappa^2 * y+sqrt(3) * sqrt(27 * Kappa^4 * y^2+4 * Kappa^3))^(1/3))-((1+1i * sqrt(3)) * (9 * Kappa^2 * y+sqrt(3) * sqrt(27 * Kappa^4 * y^2+4 * Kappa^3))^(1/3))/(2 * 2^(1/3) * 3^(2/3) * Kappa);

        x = direction * real(x_wa2);
    else
        x = [0; 0]; % should not happen
    end
end

This is Matlab Code (sorry) but gives results for all possible combinations for $k$ and $x$. The constraint for $k$: $$ k > -\frac{4}{27 y^2} $$ Not sure whether I was wrong, or the difference is because I used x, wheres WA uses y.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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