# Solve trigonometric equation: $1 = m \; \text{cos}(\alpha) + \text{sin}(\alpha)$

Dealing with a physics Problem I get the following equation to solve for $\alpha$

$1 = m \; \text{cos}(\alpha) + \text{sin}(\alpha)$

Putting this in Mathematica gives the result:

$a==2 \text{ArcTan}\left[\frac{1-m}{1+m}\right]$

However I am unable to get this result myself. No matter what I try normal equation transformations or rewriting the equation with the complex e-Function ..., everything fails. Even going the other Direction from Mathematica's Solution to my original equation resulted in nothing sensible.

Any help of how to do do this transformation is very much appreciated.

Added: As explained in the comments, 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 the same trigonometric function. Since all [direct] trigonometric functions of the simple angle can be expressed rationally as a function of the $\tan$ of the half-angle, such a conversion is adequate for these equations.

Since $$\cos \alpha =\frac{1-\tan ^{2}\frac{\alpha }{2}}{1+\tan ^{2}\frac{% \alpha }{2}}$$

and

$$\sin \alpha =\frac{2\tan \frac{\alpha }{2}}{1+\tan ^{2}% \frac{\alpha }{2}}$$

$$m\cos \alpha +\sin \alpha =1$$

is equivalent to

$$m-m\tan ^{2}\frac{\alpha }{2}+2\tan \frac{\alpha }{2}=1+\tan ^{2}\frac{\alpha }{2}.$$

One may set $x=\tan \frac{\alpha }{2}$ ($\alpha =2\arctan x$), and thus get the quadratic equation

$$\left( 1+m\right) x^{2}-2x+1-m=0.$$

Its solutions are: $x=\frac{1}{m+1}\left( -m+1\right)$ (if $m\neq -1$) or $% x=1$ (if $m=-1$), which gives

i) If $m\neq -1$,

$$\alpha =2\arctan x=2\arctan \frac{1-m}{m+1},$$

ii) If $m=-1,$

$$\alpha =2\arctan 1=\frac{\pi }{2}.$$

A different technique to solve a linear equation in $\sin \alpha$ and $\cos \alpha$ is to use an auxiliary angle $\varphi$. If you set $m=\tan \varphi$, your equation takes the form

$$\sin \alpha +\tan \varphi \cdot \cos \alpha =1$$

or

$$\sin (\alpha +\varphi )=\cos \varphi =\frac{1}{\pm \sqrt{1+\tan ^{2}\varphi }}=\pm \sqrt{\frac{1}{1+m^{2}}},$$

and obtain

$$\alpha =\pm \arcsin \sqrt{\frac{1}{1+m^{2}}}-\arctan m.$$

Detailed derivation: from $m\cos \alpha +\sin \alpha =1$ and $m=\tan \varphi$, we get

$$\sin \alpha +\tan \varphi \cdot \cos \alpha =1\iff\sin \alpha +\dfrac{\sin \varphi }{\cos \varphi }\cdot \cos \alpha =1$$

$$\iff\dfrac{\sin \alpha \cdot \cos \varphi +\sin \varphi \cdot \cos \alpha }{\cos \varphi }=1\iff\dfrac{\sin \left( \alpha +\varphi \right) }{\cos \varphi }=1$$

$$\iff\sin \left( \alpha +\varphi \right) =\cos \varphi .$$

The identity

$$\cos \varphi =\pm \sqrt{\dfrac{1}{1+\tan ^{2}\varphi }}$$

can be obtained as follows

$$\sin ^{2}\varphi +\cos ^{2}\varphi =1\iff\dfrac{\sin ^{2}\varphi }{\cos ^{2}\varphi }+1=\dfrac{1}{\cos ^{2}\varphi }$$

$$\iff\tan ^{2}\varphi +1=\dfrac{1}{\cos ^{2}\varphi }\iff\cos ^{2}\varphi =\dfrac{1}{1+\tan ^{2}\varphi }.$$

Therefore

$$\sin \left( \alpha +\varphi \right) =\pm \sqrt{\dfrac{1}{1+\tan ^{2}\varphi }}\iff\alpha +\varphi =\arcsin \left( \pm \sqrt{\dfrac{1}{1+\tan ^{2}\varphi }}\right)$$

$$\iff\alpha +\arctan m=\arcsin \left( \pm \sqrt{\dfrac{1}{1+m^{2}}}\right) \qquad (m=\tan \varphi,\ \varphi =\arctan m)$$

and finally

$$\alpha =\arcsin \left( \pm \sqrt{\dfrac{1}{1+m^{2}}}\right) -\arctan m.$$

• For instance $\cos \alpha =\frac{1-\tan ^{2}\frac{\alpha }{2}}{1+\tan ^{2}% \frac{\alpha }{2}}$ can be derived as follows $\cos \alpha =\cos ^{2}\frac{\alpha }{2}-\sin ^{2}\frac{\alpha }{2}$ $=\frac{% \cos ^{2}\frac{\alpha }{2}-\sin ^{2}\frac{\alpha }{2}}{\cos ^{2}\frac{\alpha }{2}+\sin ^{2}\frac{\alpha }{2}}$ $=\frac{1-\tan ^{2}\frac{\alpha }{2}}{1+\tan ^{2}\frac{\alpha }{2}}$. – Américo Tavares Nov 6 '10 at 18:42
• @Américo Of course. But what inspired you to start with precisely these relations, among the myriad that are available? – whuber Nov 6 '10 at 20:36
• @whuber: it was a Theorem in my 1967 Trigonometry text book (J. Calado, Compêndio de Trigonometria) that states, and proves: "All [direct] trigonometric functions of the double angle can be expressed rationally as a function of the simple angle tangent." (my translation). – Américo Tavares Nov 6 '10 at 20:49
• @Américo OK, but why were you thinking of half/double angles in the first place? (Put yourself in the position of someone confronted with the original problem, not of someone who knows the answer and is just seeking another clever demonstration thereof.) – whuber Nov 6 '10 at 20:52
• @whuber, You are welcome! My memory was very much assisted in this case because I have that book in front of me. – Américo Tavares Nov 6 '10 at 21:33

Consider the equation $$a\cos t+b\sin t=c$$ as an equation for $t$. Here $a$ and $b$ are real numbers, not both zero. The trick to solve this is to divide by $\sqrt{a^2+b^2}$ to get $$\frac{a}{\sqrt{a^2+b^2}}\cos t+\frac{b}{\sqrt{a^2+b^2}}\sin t =\frac{c}{\sqrt{a^2+b^2}},$$ equivalently $$a'\cos t+b'\sin t=c'$$ where now $a'^2+b'^2=1$. This means that $(a',b')$ lies on the unit circle. There is then an angle $u$ so that $(a',b')=(\cos u,\sin u)$. The equation becomes $$\cos u\cos t+\sin u\sin t=c',$$ that is $$\cos(t-u)=c'.$$ We see there is a solution for $t$ iff $|c'|\le1$. In general when $|c'|<1$ there are exactly two solutions for $t$ modulo $2\pi$.

(All of this is standard A-level maths.)

• @ftiaronsem: Note that Robin divided by $\sqrt{a^2+b^2}$, which is the hypotenuse of the triangle spanned by the points $(a,b)$, $(a,0)$ and $(0,0)$. – AD. Nov 6 '10 at 13:14
• thank you for your answer, I will look into it this evening, as soon as I get home again. Thanks. – ftiaronsem Nov 6 '10 at 13:48
• Note, too, that this approach can be motivated by the trig sum formulae: if we can express a = cos(something) and b = sin(same thing) [or a = sin() and b = cos()] then the lhs looks like the cos [or sin] of a sum. For this to work we need a^2 + b^2 = 1, which we can guarantee by @Robin's "trick". This motivation shows it's not a mere trick, but rather the result of some creative pattern matching. – whuber Nov 6 '10 at 20:57
• Finally I was also able to look into this answer, but I ran into a problem, while trying to solve the equation for $alpha$. $\cos(t-u)=c' \Rightarrow t = arccos(c') + u = arccos(\frac{c}{\sqrt{a^2+b^2}}) + arccos(a') = arccos(\frac{c}{\sqrt{a^2+b^2}}) + arccos(\frac{a}{\sqrt{a^2+b^2}})$ This is however not the correct solution. Where is my mistake? Thanks in advance. – ftiaronsem Nov 7 '10 at 9:46
• You are assuming that $b\ge0$, which may not be the case. Also, in general there are two solutions - you are neglecting one of them. – Robin Chapman Nov 7 '10 at 14:11

Yet another approach, which is very specific to this problem:

$$\begin{eqnarray} 1 - \sin\alpha &=& m \cos\alpha \\ \left( 1 - \sin\alpha \right)^2 &=& m^2 \cos^2\alpha \\ \left( 1 - \sin\alpha \right)^2 &=& m^2 ( 1 - \sin\alpha )( 1 + \sin\alpha ) \\ \left( 1 - \sin\alpha \right)\left((1 - \sin\alpha ) - m^2(1+\sin\alpha)\right) &=& 0 \\ \left( 1 - \sin\alpha \right)\left( (1-m^2) - ( 1 + m^2 )\sin\alpha \right) &=& 0 \end{eqnarray}$$

So, $\sin\alpha=1$ or $\sin\alpha=\frac{1-m^2}{1+m^2}$.

Note that, if $\sin\alpha=1$, then your original equation reduces to the $m$-less tautology, "$0=0$".

In the second case, a little manipulation shows relations between $m$ and other trig functions of $\alpha$. For instance, you could substitute back into your original equation to get

$$1 = m\cos\alpha + \frac{1-m^2}{1+m^2} \;\;\; \Longrightarrow \;\;\; \cos\alpha=\frac{2m}{1+m^2}$$

from which you can get

$$\tan\alpha = \frac{\sin\alpha}{\cos\alpha} = \frac{1-m^2}{2m}$$

and

$$\tan\frac{\alpha}{2}=\frac{1-\cos\alpha}{\sin\alpha} = \frac{(1-m)^2}{1-m^2}=\frac{1-m}{1+m}$$

whichever you prefer.

• Note: While the nice factorization and thereafter is "very specific to this problem", the strategy behind the first couple of steps ("rewrite everything in terms of just one trig function") is often worth trying in general. – Blue Nov 6 '10 at 21:44
• Thank you for you answer, it is indeed a very nice factorization. – ftiaronsem Nov 7 '10 at 9:56

So you have $1 = m\cos{\alpha} + \sin{\alpha}$. Now you have $1+m = m(\cos{\alpha}+1) + \sin\alpha$ and $1-m = m(\cos\alpha -1) + \sin{\alpha}$. So then you have $$\frac{1-m}{1+m} = \frac{m(\cos\alpha-1) + \sin\alpha}{m(\cos\alpha +1) + \sin\alpha} = \frac{-m \tan\frac{\alpha}{2} + 1}{m\cot\frac{\alpha}{2} + 1}$$ using the half angle formulae's. Then cross multiplying and solving you should be able to get the value of $\alpha$

• I like this. Half-angle tangents are very useful sorts. :) – J. M. is a poor mathematician Nov 6 '10 at 11:29
• thank you for your answer, I will look into it this evening, as soon as I get home again. Thanks. – ftiaronsem Nov 6 '10 at 13:45
• Finally I looked through your answer, but unfortunatelly I indeed don't get it ;-) Taking your equation, i get: $\frac{m(\cos\alpha-1) + \sin\alpha}{m(\cos\alpha +1) + \sin\alpha}=\frac{m\frac{(\cos\alpha-1)}{sin\alpha} + 1}{m\frac{(\cos\alpha +1)}{sin\alpha} + 1}$ According to wikipedia this would translate to: $\frac{-m \tan\frac{\alpha}{2} + 1}{m\cot\frac{\alpha}{2} + 1}$ However assuming that you ment the cot in your original equation, I was unable to resolve to $\alpha$. Can you please give me another hint? Thank you very much. – ftiaronsem Nov 7 '10 at 9:38

Since we are adding different proofs, here is a geometric one, for the special case when $m > 0$ and $\alpha$ is acute.

We use the Law of Tangents which states, that in a triangle

the identity

$$\frac{a-b}{a+b} = \frac{\tan\frac{\alpha - \beta}{2}}{\tan\frac{\alpha+\beta}{2}}$$

holds.

Now consider the below triangle

We have $\displaystyle \angle{BCA} = \alpha$, $\displaystyle \angle{CBA} = \pi/2$ and $\displaystyle \angle{CAB} = \pi/2 - \alpha$.

ABC is a right angled triangle with $\displaystyle AC = 1 = m\cos\alpha + \sin \alpha$. Point $\displaystyle D$ is chosen on $\displaystyle AC$ such that $\displaystyle AD = \sin \alpha$ and so $\displaystyle DC = m\cos \alpha$. We also have $\displaystyle BC = \cos \alpha$ and $AB = \sin \alpha$.

Now $\displaystyle AD = \sin \alpha = AB$ and so $\triangle ABD$ is isoceles and hence $\displaystyle \angle{ABD} = \angle{ADB} = \pi/4 + \alpha/2$.

Thus we have that

$\displaystyle x = \angle{CDB} = 3\pi/4 - \alpha/2$ and $\displaystyle y = \angle{CBD} = \pi/4-\alpha/2$

Now apply the law of tangents to $\displaystyle \triangle BCD$.

We get

$$\frac{\cos \alpha - m\cos\alpha}{\cos\alpha + m\cos\alpha} = \frac{\tan (x/2 - y/2)}{\tan(x/2 + y/2)}$$

$$= \frac{\tan(\pi/4)}{\tan(\pi/2 - \alpha/2)} = \tan(\alpha/2)$$

Thus

$$\frac{1-m}{1+m} = \tan(\alpha/2)$$

• Thank you for your answer. Its fascinating that there are so many possibilities for solving this... – ftiaronsem Nov 7 '10 at 10:14

Because you're familiar with complex exponentials, all you needed to succeed is to observe that by setting $w = m - i$ your equation becomes

$$w \exp(i \alpha) + \bar{w} \exp(-i \alpha) = 2.$$

(Edit What might motivate this choice of $w$? Well, if you're thinking of complex numbers you're thinking that $\cos(\alpha) + i \sin(\alpha) = \exp(i \alpha)$. To obtain $m \cos(\alpha) + \sin(\alpha)$ from this you need to multiply $\cos(\alpha)$ by $m$ and $i \sin(\alpha)$ by $-i$. Thus it's automatic to set out by computing

$$(m - i)(\cos(\alpha) + i \sin(\alpha)) = \left(m \cos(\alpha) + \sin(\alpha)\right) + \left(\text{real stuff}\right) i.$$

The real part of this expression is exactly what you need, whence the original equation reads

$$1 = \mathbb{Re}\left(w \exp(i \alpha))\right) = \frac{w \exp(i \alpha) + \overline{w \exp(i \alpha)}}{2} = \frac{w \exp(i \alpha) + \bar{w} \exp(-i \alpha)}{2}.$$

Multiply by 2 to clear the fraction. End of edit)

Setting $z = \exp(i \alpha)$ to simplify the notation yields

$$w z^2 - 2 z + \bar{w} = 0,$$

with two generic solutions by the quadratic formula:

$$z = \frac{1 + \sqrt{1 - |w|^2}}{w}, \quad z = \frac{1 - \sqrt{1 - |w|^2}}{w}.$$

Because $\sqrt{1 - |w|^2} = \pm m i$, the solutions simplify to

$$z = \frac{i + m}{1 + m i}, \quad z = i.$$

(Once again we see a connection to fractional linear transformations, as per @Qiaochu Yuan's comment.)

By definition, $\alpha$ is the argument (polar coordinate) of a solution $z$. Writing $\tan(\theta) = m$ (which defines $\theta$ up to an integral multiple of $\pi$), the argument of the denominator is $\theta$ while the argument of the numerator is equal to $\pi/2 - \theta$. Whence

$$\alpha = \pi/2 - 2\theta \quad \text{or} \quad \alpha = \pi/2$$

(both modulo an integral multiple of $2 \pi$).

If you prefer, in the first case you may write

$$\alpha = \pi/2 - 2\arctan(m).$$

The second case obviously gives the trivial solutions $1 = m \cos(\pi/2 + 2 n \pi) + \sin(\pi/2 + 2 n \pi)$ $= m 0 + 1.$

The first solution appears to be a new one, but it's equivalent to the others that have been obtained. As a check, we may assume $\theta$ is not an odd multiple of $\pi/2$, whence $\alpha$ is not an odd multiple of $\pi/2$, and compute

$$m \cos(\alpha) + \sin(\alpha)$$

$$= \tan(\theta) \cos(\pi/2 - 2 \theta) + \sin(\pi/2 - 2\theta) = \tan(\theta) \sin(2 \theta) + \cos(2 \theta)$$

$$= \frac{\sin(\theta)}{\cos(\theta)}\left(2 \sin(\theta) \cos(\theta)\right) + \left(\cos(\theta)^2 - \sin(\theta)^2\right)$$

$$= \sin(\theta)^2 + \cos(\theta)^2 = 1.$$

Although for a problem like this I would ordinarily take the route described by @Robin Chapman, I like this complex number approach because it produces a simpler solution (which actually is defined for $m = -1$, btw) by means of straightforward techniques and it explicitly produces all solutions. When $m \lt -1$ and we use the standard branch of the arctangent it differs by $2 \pi$ from the one Mathematica obtained, but that's of no consequence. (It's curious that Mathematica cannot tell these two solutions are the same, even when you restrict the domain to real nonnegative $m$. A plot of their difference will remove any lingering doubts.)

• A solution by @Américo Tavares appeared while I was writing this one. The two are related because both generate closely related quadratic equations. Américo's has the advantage of using only real coefficients. I'm glad I didn't have to know those cosine-tangent and sine-tangent identities, though! – whuber Nov 6 '10 at 18:01
• A +1 because I can't (and don't want to) remember them all, either. :) – J. M. is a poor mathematician Nov 6 '10 at 20:41
• Thanks for the answer, this is really a nice solution too. – ftiaronsem Nov 7 '10 at 10:13

Another:

$$\begin{eqnarray} \frac{1-\sin\alpha}{\cos\alpha} &=& m \\ \frac{1-\cos\left(\frac{\pi}{2}-\alpha\right)}{\sin\left(\frac{\pi}{2}-\alpha\right)} &=&m \\ \tan\frac{\frac{\pi}{2}-\alpha}{2} = \tan\left(\frac{\pi}{4}-\frac{\alpha}{2}\right) &=& m \\ \frac{\tan\frac{\pi}{4}-\tan\frac{\alpha}{2}}{1+\tan\frac{\pi}{4} \tan\frac{\alpha}{2}} = \frac{1-\tan\frac{\alpha}{2}}{1+\tan\frac{\alpha}{2}} &=& m \\ \Longrightarrow \tan\frac{\alpha}{2} &=& \frac{1-m}{1+m} \end{eqnarray}$$

• Thank you for your answer. Its fascinating that there are so many possibilities for solving this... – ftiaronsem Nov 7 '10 at 10:14