Sign up ×
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.

In the equation $$x\cos(\theta) + y\sin(\theta) = z,$$ how do I solve in terms of $\theta$? i.e $\theta = \dots$.

share|cite|improve this question
Linear equations in $\sin \theta$ and $\cos \theta$ can be solved by a resolvent quadratic equation. One method is to write the $\sin \theta$ and $\cos \theta$ functions in terms of the $\tan (\theta/2)$. –  Américo Tavares Apr 15 '11 at 15:44

3 Answers 3

There are various possible strategies. I will mention one approach. Of course if there is a solution, there are infinitely many, since we can add $2\pi$ to any solution and get another solution.

Let's change notation a little. We are interested in the equation $$a\cos\theta + b\sin\theta=q$$

Rewrite this equation as $$\frac{a}{\sqrt{a^2+b^2}}\cos\theta+ \frac{b}{\sqrt{a^2+b^2}}\sin\theta=\frac{q}{\sqrt{a^2+b^2}}$$ Now let $\phi$ be the angle whose sine is $a/\sqrt{a^2+b^2}$ and whose cosine is $b/\sqrt{a^2+b^2}$. By a formula that I hope is familiar (sine of a sum of angles), the equation can be rewritten as $$\sin(\phi+\theta)=\frac{q}{\sqrt{a^2+b^2}}$$ Look at the right-hand side. If its absolute value is greater than $1$, there will be no (real) solution. Otherwise, for simplicity, call the right-hand side $w$. Then we can write that $\phi+\theta=\arcsin w$ or $\phi+\theta=\pi-\arcsin w$. Now remember that whatever solutions you get through this process, anything obtained by adding $2n\pi$, where $n$ is an integer, to a solution, is also a solution.

The reason I went in detail through this approach is that in Physics, it is often important to express $a\cos\theta+b\sin\theta$ in the form $c\sin(\phi+\theta)$ that we used to solve the equation. There are other approaches.

share|cite|improve this answer
Almost right, but you slipped at the end: $\sin(\phi+\theta)=\sin(w)$ means that $\phi+\theta$ belongs to $\arcsin(w)+2\pi\mathbb{Z}$ or to $\pi-\arcsin(w)+2\pi\mathbb{Z}$. –  Did Apr 15 '11 at 16:14
You did not get what I wrote: unless $|w|=1$, the set of solutions of the equation $\sin(\phi+\theta)=w$ cannot be written as the set of $\theta_0+2n\pi$, for a well chosen $\theta_0$ and for every integer $n$. So your solution as written is false. –  Did Apr 15 '11 at 16:36
@Didier Pau: Sorry, I missed part of the content of your comment. I have edited the answer to take account of what you wrote. –  André Nicolas Apr 15 '11 at 16:37

This expands my comment above. As I wrote here "certain trigonometric equations such as the linear equations in $\sin x$ and $\cos x$ can be solved by a resolvent quadratic equation. One method is to write the $\sin x$ and $\cos x$ functions in terms of (...) $\tan$ of the half-angle".

Applying this method, since

$$\cos \theta =\frac{1-\tan ^{2}\frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2% }}\qquad\text{and}\qquad\sin \theta =\frac{2\tan \frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2}},$$

your equation is equivalent to

$$x\frac{1-\tan ^{2}\frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2}}+y\frac{% 2\tan \frac{\theta }{2}}{1+\tan ^{2}\frac{\theta }{2}}=z.$$

Let $u=\tan \frac{\theta }{2}$. Then we can write it as

$$\left( x+z\right) u^{2}-2yu+z-x=0,$$

which has the solutions

$$u=\tan \frac{\theta }{2}=\frac{1}{2\left( x+z\right) }\left( 2y\pm2\sqrt{% y^{2}+x^{2}-z^{2}}\right).$$


$$\theta =2\arctan \left( \frac{1}{ x+z }\left( y\pm % \sqrt{y^{2}+x^{2}-z^{2}}\right) \right) +2n\pi,\qquad n\in\mathbb{Z} .$$

This method is valid iff $\theta \neq (2k+1)\pi $, with $k\in\mathbb{Z}$.

A different technique is to use an auxiliary angle.

share|cite|improve this answer
Thank you! I had a math teacher that insisted Math was a sport. –  user9624 Apr 15 '11 at 16:58
You are welcome! I adapted this technique from my 1967 Trigonometry text book (J. Calado, Compêndio de Trigonometria), where it is presented and worked out in detail. I deleted my explanation of the auxiliary angle technique (answered before by user6312). –  Américo Tavares Apr 15 '11 at 21:13

Let us introduce $c=\cos \theta$. Then your equation reads $$x c + s y \sqrt{1-c^2} =z$$ where $s=\pm 1$ is related to the quadrant of $\theta$ (+1 in the first and second quadrant and -1 in the third and forth). Subtracting $x c$ from both sides then squaring the equation yields $$y^2 (1-c^2) = (z- xc)^2 = z^2 -2 zx c + x^2 c^2.$$ This is a quadratic equation with the solutions $$ c_\pm = \frac{x z \pm y \sqrt{x^2+ y^2 - z^2}}{x^2 + y^2}.$$ In order that $c_\pm$ are real, we need $z^2 \leq x^2+y^2$. As we have squared the equation, we have to check whether $c_\pm$ solves the original equation. Indeed, $c_\pm$ solves the original equation with $s_\pm=\text{sgn}[(z-xc_\pm)/y]$. Therefore, we have the two solutions (mod $2\pi$) $$\theta = s_\pm \arccos(c_\pm). $$

share|cite|improve this answer
Hmmm... I doubt that. First, both solutions $c_+$ and $c_-$ of the quadratic equation are admissible. Second, the set of solutions $\theta$ is either empty or of the form $a\pm b+2\pi\mathbb{Z}$. –  Did Apr 15 '11 at 16:10
@Didier Piau: thank you, I corrected the mistake. Regarding the $+2\pi \mathbb{Z}$, as $\theta$ is an angle everything is mod $2\pi$. –  Fabian Apr 15 '11 at 16:18
Did you check that $|c_\pm|\le1$? You know, me saying so should not be enough... And I am not sure I follow your dealing with the signs. –  Did Apr 15 '11 at 16:31
@Didier Piau: yes I check it (I actually started writing the edited post before I read your comment...) –  Fabian Apr 15 '11 at 16:33
@Didier Piau: the signs are easy. When I square the equation, I have a √ on one side and $(z-xc)/sy$ on the other. The latter should be positive for the equality to hold. –  Fabian Apr 15 '11 at 16:36

Your Answer


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