# Isolating $θ$ in $a \sin^2 \theta + b \sin \theta + c + d \cos^2 \theta + e \cos \theta + f = 0$. [closed]

I have an equation that follows this form:

$$a \sin^2 \theta + b \sin \theta + c + d \cos^2 \theta + e \cos \theta + f = 0$$ where $$a,b,c,d,e,f \in \mathbb{R}$$ and $$a\neq 0, d\neq 0$$. I am trying to isolate $$θ.$$

How can this be achieved?

• Please don't use pictures. See here, why. Use MathJax. Here is a tutorial. Nov 15, 2022 at 17:20
• Group $c$ and $f$ together on the other side; $a \sin^2\theta + b \cos^2 \theta + b\sin\theta + e\cos\theta = - (c+f)$. Eyeballing this, I have a feeling that you need some greater assumptions on the coefficients/ this won't be solvable in general ($\sin$ and $\cos$ are, of course, not invertible over $\mathbb{R}$). Linked is a similar quadratic in two variables -- think $\sin$ and $\cos$; I haven't worked anything out, but that $\sin \rightarrow [0,1]$ is definitely hairy.
– user838358
Nov 15, 2022 at 17:42
• Thank you @mjachi the question has been edited with the MathJax formatting. Nov 15, 2022 at 18:00
• Huh??? "Isolating 0"????? Nov 15, 2022 at 20:25
• @DavidG.Stork Sorry, should be fixed now. Nov 15, 2022 at 20:29

You can convert this expression to a 4-th order polynomial using a wassestrass substitution

$$\cos \theta = \frac{1-t^2}{1+t^2}$$ $$\sin \theta = \frac{2 t}{1+t^2}$$

which converts the trig expression into the following polynomial

$$a \frac{4 t^2}{(1+t^2)^2} +b \frac{2 t}{1+t^2} + c +d \frac{(1-t^2)^2}{(1+t^2)^2} + e \frac{1-t^2}{1+t^2}+f =0$$

Multiply the whole thing by $$(1+t^2)^2$$ to get a 4-order polynomial in terms of $$t$$.

After you solve for $$t$$, then use $$\theta = 2 \tan^{-1} (t)$$

You can prove the above by using $$t = \tan \left( \tfrac{\theta}{2} \right)$$ and use trig identities.

I have another solution that involves reducing the order of the expression into a 3rd-order polynomial and then solving that.

1. Consider the solution as having two parts, $$\theta = \alpha + \beta$$, and using this in the original expression. Expand all the trig addition terms to get $$\small \begin{gather} \cos^2 \alpha (a - (a-d) \cos^2 \beta) + \underbrace{ \cos \alpha \left( 2 (a-d) \sin \alpha \sin \beta \cos \beta + e \cos \beta + b \sin \beta \right)}_\text{assume = 0} + \\ + \sin^2 \alpha (d + (a-d) \cos \beta^2) + \sin \alpha ( b \cos \beta - e \sin \beta) + c + f = 0 \end{gather}$$

2. Since $$\alpha$$ and $$\beta$$ are somewhat arbitrary we can find the value of $$\alpha$$ that makes the underlying part above zero. This way the above expression is "simplified" by removing this term, and the remaining expression is only in terms of $$\beta$$ $$\alpha = \sin^{-1} \left( \tfrac{b}{2(d-a)\cos \beta} + \tfrac{e}{2(d-a) \sin \beta} \right)$$

3. The remaining expression contains only even powers of $$\sin \beta$$ and $$\cos \beta$$ which can all be collected into one variable by substituting $$s = \sin^2 \beta$$ and derive this 3-rd order polynomial in terms of $$s$$ $$\small \begin{gathered} \underbrace{ 4 (a-d)^3}_{k_3} \;s^3 + \underbrace{ -4 \left( a^3-a^2 (c+4 d+f)+a d (2 c + 5 d + 2 f)-d^2 (c+2 d+f)\right)}_{k_2}\; s^2 + \\ + \underbrace{-4 a^2 (c+d+f) + a (b^2 +8 c d + 8 d^2 + 8 d f + e^2) - d ( b^2 + 4 c d + 4 d^2 + 4 d f+e^2)}_{k_1}\; s + \underbrace{d e^2-a e^2}_{k_0} = 0 \end{gathered}$$ where the $$k_0$$, $$k_1$$, $$k_2$$ and $$k_3$$ coefficients are known and defined as above in $$k_0 + k_1 s + k_2 s^2 + k_3 s^3 = 0$$

4. Eliminate the quadratic term with the substitution $$s = -\tfrac{k_2}{3 k_3} + \tfrac{1}{k_3^{1/3}} t$$

$$\underbrace{ \left( k_0 - \tfrac{k_1 k_2}{3 k_3} + \tfrac{2 k_2^2}{27 k_3^2} \right) }_{v} + \underbrace{\left( \tfrac{k_1}{k_3^{1/3}} - \tfrac{k_2^2}{3 k_3^{4/3}} \right) }_{u}\,t + t^3 = 0$$

to get $$v + u \,t + t^3 =0$$ with known coefficients $$u$$ and $$v$$.

5. One more substitution, this time to reduce the 3rd order equation above into a 2rd order quadratic which is solvable. Use $$t = z^{1/3} - \tfrac{u}{3 z^{1/3}}$$ in the equation above to get $$\frac{27 z^2 + 27 v\,z - u^3}{27 z} =0$$ and solve for $$z$$

The two solutions are $$z = -\tfrac{v}{2} \pm \sqrt{ \tfrac{u^3}{27} + \tfrac{v^2}{4} }$$

6. Back substitutions \begin{aligned} t & = z^{1/3} - \tfrac{u}{3 z^{1/3}} \\ s & = -\tfrac{k_2}{3 k_3} + \tfrac{1}{k_3^{1/3}} t \\ \beta &= \sin^{-1}( \sqrt{s}) \\ \alpha &= \sin^{-1} \left( \tfrac{b}{2(d-a)\cos \beta} + \tfrac{e}{2(d-a) \sin \beta} \right) \\ \theta & = \alpha + \beta \end{aligned}

• See the update to the solution of the problem by progressively reducing the order of the polynomial via some smart substitutions. Nov 15, 2022 at 19:56
• Reducing it to a 3rd-order polynomial is impressive! Here I was, adding a quartic equation solver to my project. I will try your approach and get back with results. Nov 15, 2022 at 20:23
• @AlexMillette - this is how I solve $a \sin \theta + b \cos \theta + c =0$ equations. Make $\theta = \alpha + \beta$ and expand out. Then make some part of the expansion zero by finding $\alpha$ and then solve for $\beta$. I wanted to give it a try like this for this more complex problem, and I was surprised to see reduce to even powers of $\sin$ and $\cos$ which made it solvable. Nov 15, 2022 at 20:50
• The approach appears to fail in a case where $a=d$, since $k_3$ will be 0. I suppose in that case we can fall back to a quadratic solving? In fact, only $k_2$ won't be zero in such a case. Nov 15, 2022 at 22:15
• @AlexMillette - yeah I have not invested any time exploring the edge cases. Nov 16, 2022 at 0:04

You can convert this expression to a $$4$$-th order polynomial with the Expotential representations of the trigonometric functions and substitution these with $$t$$. You can now solve this equation with the polynomial of degree $$4$$ using a solution formula or equivalent transformation after t and then resubstitute, so that you only have to take the $$\ln()$$ and divide by $$\mathrm{i}$$:

\begin{align*} a \cdot \sin^{2}(\theta) + b \cdot \sin(\theta) + c + d \cdot \cos^{2}(\theta) + e \cdot \cos(\theta) + f &= 0 \quad\mid\quad -(c + f)\\ a \cdot \sin^{2}(\theta) + b \cdot \sin(\theta) + d \cdot \cos^{2}(\theta) + e \cdot \cos(\theta) &= -c - f \quad\mid\quad \sin(x) = \frac{e^{x \cdot \mathrm{i}} - e^{-x \cdot \mathrm{i}}}{2 \cdot \mathrm{i}} \wedge \cos(x) = \frac{e^{x \cdot \mathrm{i}} + e^{-x \cdot \mathrm{i}}}{2}\\ a \cdot \left( \frac{e^{\theta \cdot \mathrm{i}} - e^{-\theta \cdot \mathrm{i}}}{2 \cdot \mathrm{i}} \right)^{2} + b \cdot \frac{e^{\theta \cdot \mathrm{i}} - e^{-\theta \cdot \mathrm{i}}}{2 \cdot \mathrm{i}} + d \cdot \left( \frac{e^{\theta \cdot \mathrm{i}} + e^{-\theta \cdot \mathrm{i}}}{2} \right)^{2} + e \cdot \frac{e^{\theta \cdot \mathrm{i}} + e^{-\theta \cdot \mathrm{i}}}{2} &= -c - f\\ a \cdot \left( -\frac{e^{2 \cdot \theta \cdot \mathrm{i}} + e^{-2 \cdot \theta \cdot \mathrm{i}}}{4} + \frac{1}{2} \right) + b \cdot \frac{e^{\theta \cdot \mathrm{i}} - e^{-\theta \cdot \mathrm{i}}}{2 \cdot \mathrm{i}} + d \cdot \left( \frac{e^{2 \cdot \theta \cdot \mathrm{i}} + e^{-2 \cdot \theta \cdot \mathrm{i}}}{4} + \frac{1}{2} \right) + e \cdot \frac{e^{\theta \cdot \mathrm{i}} + e^{-\theta \cdot \mathrm{i}}}{2} &= -c - f\\ a \cdot -\frac{e^{2 \cdot \theta \cdot \mathrm{i}} + e^{-2 \cdot \theta \cdot \mathrm{i}}}{4} + \frac{a}{2} + b \cdot \frac{e^{\theta \cdot \mathrm{i}} - e^{-\theta \cdot \mathrm{i}}}{2 \cdot \mathrm{i}} + d \cdot \frac{e^{2 \cdot \theta \cdot \mathrm{i}} + e^{-2 \cdot \theta \cdot \mathrm{i}}}{4} + \frac{a}{2} + e \cdot \frac{e^{\theta \cdot \mathrm{i}} + e^{-\theta \cdot \mathrm{i}}}{2} &= -c - f\\ a \cdot -\frac{\left( e^{\theta \cdot \mathrm{i}} \right)^{2} + \left( e^{\theta \cdot \mathrm{i}} \right)^{-2}}{4} + \frac{a}{2} + b \cdot \frac{e^{\theta \cdot \mathrm{i}} - \left( e^{\theta \cdot \mathrm{i}} \right)^{-1}}{2 \cdot \mathrm{i}} + d \cdot \frac{\left( e^{\theta \cdot \mathrm{i}} \right)^{2} + \left( e^{\theta \cdot \mathrm{i}} \right)^{-2}}{4} + \frac{a}{2} + e \cdot \frac{e^{\theta \cdot \mathrm{i}} + \left( e^{\theta \cdot \mathrm{i}} \right)^{-1}}{2} &= -c - f \quad\mid\quad t := e^{\theta \cdot \mathrm{i}}\\ a \cdot -\frac{t^{2} + t^{-2}}{4} + \frac{a}{2} + b \cdot \frac{t - t^{-1}}{2 \cdot \mathrm{i}} + d \cdot \frac{t^{2} + t^{-2}}{4} + \frac{a}{2} + e \cdot \frac{t + t^{-1}}{2} &= -c - f \quad\mid\quad -a\\ a \cdot -\frac{t^{2} + t^{-2}}{4} + b \cdot \frac{t - t^{-1}}{2 \cdot \mathrm{i}} + d \cdot \frac{t^{2} + t^{-2}}{4} + e \cdot \frac{t + t^{-1}}{2} &= -c - f - a \quad\mid\quad -(-c - f - a)\\ -a \cdot \frac{t^{2} + t^{-2}}{4} + b \cdot \frac{t - t^{-1}}{2 \cdot \mathrm{i}} + d \cdot \frac{t^{2} + t^{-2}}{4} + e \cdot \frac{t + t^{-1}}{2} + c + f + a &= 0 \quad\mid\quad \cdot t^{2}\\ -a \cdot \frac{t^{4} + 1}{4} + b \cdot \frac{t^{3} - t}{2 \cdot \mathrm{i}} + d \cdot \frac{t^{4} + 1}{4} + e \cdot \frac{t^{3} + t}{2} + c + f + a &= 0\\ \end{align*}