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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In the attached image are three functions. The first is a displacement function which takes angle $t$, and returns a radius. The third one is a semicircle and the second one is a semicircle with the displacement function $d()$ applied.

Note that the second function includes $y$ in the right hand side (inside $\text{atan2}$). I need to factor this equation so that it is entirely dependent on $x$, and there is no $y$ variable on the right hand side of the equation.

Reproduced here, the equation is:

$y=\sqrt{ d(\text{atan2}( y, x ) )^2 - x^2 }$

I need to get this ^ y moved to the left.


edit: bigger picture, I'm trying to do raycasting of a sphere with a displacement map using an orthographic camera. This is why I only care about the greatest y, because lower y are not visible to the camera due to occlusion. My thought was that if I could scan across with a single x, on a 2 dimension version of the problem I'd be closer to solving the 3 dimensional version.

edit: let me ask this a different way. Given a line, how can I find the location of a the points which this line intersects with the equation?

edit again: it seems the answer is binary search.

share|cite|improve this question
Welcome to Math.SE! No apologies necessary; this is a perfectly well-formed question. But right off the bat, I can tell you that if you want $y$ to be purely a function of $x$, this is impossible, because for some values of $x$ (like around $x = 0.8$) there are multiple values of $y$ on the curve. – Rahul Feb 13 '12 at 9:20
thank you for your reply. What I would like is, where there are multiple y, I want the greatest, or maximum y. Is that possible? – Breton Feb 13 '12 at 9:36
up vote 4 down vote accepted

As Rahul has already commented, you can't solve this for $y$ because $y$ is not a single-valued function of $x$. I also doubt that you can express the greatest $y$ for a given $x$ in closed form.

In polar coordinates, your equation is just $r(\phi)=d(\phi)$, and this allows you to write both $x$ and $y$ as functions of the single parameter $\phi$:

$$ x=r\cos\phi=d(\phi)\cos\phi\;,\\ y=r\sin\phi=d(\phi)\sin\phi\;. $$

Now you could express $y$ as a function of $x$ if you could solve the first of these equations for $x$. With $d(\phi)=1+\sin(20\phi)/5$, this is $x=(1+\sin(20\phi)/5)\cos\phi$. You could express $\sin(20\phi)$ in terms of $\sin\phi$ and $\cos\phi$, but that would lead to a high-order polynomial in $\sin\phi$ and $\cos\phi$ whose roots are unlikely to have a closed form.

Often people post questions about parts of their problems, which turn out to be unsolvable because they've gone down a dead end with their bigger problem. If you tell us why you want to do this, we might be able to help you more, e.g. by suggesting how to do it in polar coordinates instead.

[Edit in response to the edit in the question:]

You could consider scanning through values of $\phi$ instead. Since

$$\dot x=\dot d\cos\phi-d\sin\phi=4\cos(20\phi)\cos\phi-(1+\sin(20\phi)/5)\sin\phi$$

(where the dot signifies differentiation with respect to $\phi$), you have $\Delta x\lt\sqrt{4^2+1.2^2}\Delta\phi\approx4\Delta\phi$, so with $\phi\in[0,\pi]$ instead of $x\in[-1.2,1.2]$ you'd only need about five times as many steps to get the same density of $x$ values everywhere.

share|cite|improve this answer
"...whose roots are unlikely to have a closed form." - they do have a closed form; it just happens that they're not practical. :) – J. M. Feb 13 '12 at 10:12
@J.M.: Do they? What is it? – joriki Feb 13 '12 at 10:16
Hmm, I thought it'd have to use theta functions, but after expressing $\sin\,20\phi$ in the form $p(\cos\,\phi)\sin\,\phi$, with $p(u)$ a 19th degree polynomial, it turns out that the roots of $p(u)$ are expressible as nice radicals (nested square roots). You want to see them? – J. M. Feb 13 '12 at 10:24
I have edited the original question to express my wider goals. I was rather hoping to find a solution that didn't involve breaking into d() – Breton Feb 13 '12 at 10:28
@J.M.: Sorry, I see now that that was ambiguous -- I meant the entire polynomial whose zeroes would be the values of $\phi$ corresponding to $x$, not just the polynomial for $\sin(20\phi)$. I'm not too surprised that the roots of $p$ are expressible as nested radicals, since the regular icosagon is constructible. – joriki Feb 13 '12 at 10:31

Your Answer


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.