0

I have the following equation:

$$(q\sin(\phi)\cos(\theta)-a)^2 + (q \sin(\phi)\sin(\theta)-b)^2 + (q \cos(\phi) -c)^2 =r^2$$

I am given $q,r,a,b,c$. I am able to choose either $\phi$ or $\theta$ but not both. I then have to solve this equation for one of them.

According to someone I spoke with, this is a nonlinear equation without a simple solution. Is that true? If so, can someone explain why? Does the solvability of this system depend on whether I picked $\theta$ or $\phi$?

I'm looking for the answerer to tell me

  • Is there an explicit solution for this equation?
  • If there isn't, what kind of approximation might be appropriate here? (e.g. would a Taylor series approach make sense)? I was also told that using Newton-Raphson might be appropriate, but I'm not sure.

EDIT:

I should add $q, r > 0$ and $\theta$ and $\phi$ should be able to take on any angles that satisfy this equation.

EDIT 2:

I now wish to have the problem formulated with the assumption that $\theta$ is given and we wish to solve for $\phi$.

How does one do this?

I tried the following rearrangement, but this is as far as I got. I reasoned that I should try to convert the first two terms on the LHS into some term of the form $(k\sin(\phi) - d)^2$. Therefore, I tried

\begin{align*} (q\sin(\phi)\cos(\theta)-a)^2 + (q \sin(\phi)\sin(\theta)-b)^2 &= q^2\sin^2(\phi)\cos^2(\theta) -2aq\sin(\phi)\cos(\theta)+a^2 +q^2 \sin^2(\phi)\sin^2(\theta) - 2b q \sin(\phi)\sin(\theta)+b^2 \\ &= q^2\sin^2(\phi)\cos^2(\theta)+q^2 \sin^2(\phi)\sin^2(\theta) -2aq\sin(\phi)\cos(\theta) - 2b q \sin(\phi)\sin(\theta)+a^2+b^2 \\ &= q^2\sin^2(\phi)\left(\cos^2(\theta)+\sin^2(\theta) \right)-2q\sin(\phi)\left(a\cos(\theta) + b \sin(\theta)\right)+a^2+b^2 \\ &= q^2\sin^2(\phi)-2q\sin(\phi)\left(a\cos(\theta) + b \sin(\theta)\right)+a^2+b^2 \\ \end{align*}

But this is where I got stuck and I had no idea what to do next. I feel like the next step is to convert this to "vertex form" as they say in basic algebra classes.

According to this, we have

$$f(x) = Ax^2 + Bx + C = A(x-h)^2 + k$$

where $h = -\frac{B}{2A}$ and $k = f(h)$.

Assuming I did this, I would expect to get something like

\begin{align*} A(\sin(\phi)-h)^2+k + (q \cos(\phi) -c)^2 &=r^2\\ (\sqrt{A}\sin(\phi)-\sqrt{A}h)^2 + (q \cos(\phi) -c)^2 &=r^2-k\\ \end{align*}

However, this seemed rather tedious to compute and I was wondering if there was a better way to do it.

Stan Shunpike
  • 5,293
  • 4
  • 43
  • 81
  • Wolfram says there is a solution for $\phi$ but it indeed not pretty: https://www.wolframalpha.com/input?i=%28q+sin%28phi%29+cos%28theta%29-a%29%5E2%2B%28q+sin%28phi%29+sin%28theta%29-b%29%5E2%2B%28q+cos%28phi%29-c%29%5E2%3Dr%5E2 – QC_QAOA Jan 20 '23 at 17:50
  • In geometrical terms, what you want is the intersection between a sphere of radius $q$ centered at $(a,b,c)$ and a sphere of radius $r$ centered at the origin. This solution set is almost always either a circle or empty set. You may want to start with a simpler case first; the particular case $a=b=0$ seems an appropriate starting point. – Semiclassical Jan 20 '23 at 17:57
  • 1
    @AnneBauval slip of the tongue. I had a set of equations and simplified it to this. – Stan Shunpike Jan 20 '23 at 18:08

1 Answers1

2

Choosing $\phi$ and letting $R^2=r^2-(q\cos\phi-c)^2$ and $\rho=q\sin\phi,$ your equation becomes: $$(\rho\cos\theta-a)^2+(\rho\sin\theta-b)^2=R^2,$$ which (if $\rho\ne0$) is equivalent to $$2\rho\left(a\cos\theta+b\sin\theta\right)=\rho^2+a^2+b^2-R^2,$$ i.e. to $$\cos(\theta-\alpha)=C,$$ where $$\cos\alpha=\frac a{\sqrt{a^2+b^2}},\quad\sin\alpha=\frac b{\sqrt{a^2+b^2}},\quad C=\frac{\rho^2+a^2+b^2-R^2}{2\rho\sqrt{a^2+b^2}}.$$ The solution is then $$\theta=\alpha\pm\arccos C. $$

Anne Bauval
  • 49,005
  • I added an edit. I believe we cannot assume $\rho \ne 0$ because $q$ is definitely non-zero but $\phi$ should be able to be $0$ and so, I would think this assumption would not work. I could be wrong about the implications of what I said completely, I'm just raising questions. But I know $\phi$ can equal 0. – Stan Shunpike Jan 20 '23 at 18:31
  • You said "I am able to choose either $\phi$ or $\theta$". If you choose $\phi$ s.t. $\sin\phi\ne0,$ no problem. If you choose $\phi=k\pi$ then either every $\theta\bmod{2\pi}$ is a solution, or none, depending whether $a^2+b^2=R^2$ or not. I did not include this case in my answer because it is trivial. – Anne Bauval Jan 20 '23 at 18:38
  • Im still having trouble following your logic. I get the first part about reducing the equation to essentially the equation of a circle with radius $R$. I love that part. But where does $\cos(\theta-\alpha)$ come from? I don't see intuitively what that represents. I also don't see how you derived $C$. Could you elaborate on these points? – Stan Shunpike Jan 23 '23 at 05:56
  • @StanShunpike: For the $\cos(\theta-\alpha)$ stuff, see, for instance, this question, as well as others in that question's "Linked" list. (The identity has appeared here numerous times.) – Blue Jan 23 '23 at 06:53
  • 1
    @Blue that was great! thanks so much :) – Stan Shunpike Jan 23 '23 at 19:16
  • @AnneBauval This solution is extremely clever. Worked perfectly seemingly for my purposes. Thank you! – Stan Shunpike Jan 23 '23 at 19:16
  • @StanShunpike: Glad to help! ... It's perhaps worth noting that, upon expanding and simplifying the original equation, you get something that could be written as, say, $$U\sin\theta+V\cos\theta=W \qquad\text{OR}\qquad U\sin\phi+V\cos\phi=W$$ for appropriate definitions of $U$, $V$, $W$, and then you can use the $\cos(x-\alpha)$ identity either way. So, this allows you to solve for whichever of $\theta$ and $\phi$ best suits your needs. – Blue Jan 23 '23 at 19:28
  • @Blue Omg that's amazing! Can you possibly add a version of this equation that would allow me to solve for $\phi$ instead as a separate answer? I would upvote that. I tested the $\theta$ equation and I found it actually was suboptimal for my purposes and solving for $\theta$ with $\phi$ assumed would work better. – Stan Shunpike Jan 23 '23 at 21:20
  • @Blue I tried to reformulate the problem and added my work in the original post. If you could give me some pointers on how to improve it, that would be great. Thanks again for your help! :) – Stan Shunpike Jan 24 '23 at 17:15