0
$\begingroup$

Given all variables are in $\mathbb{R}$, and $\{ a, d\} \neq 0$, solve for $\theta$:

$$a \sin^2 \theta + b \sin \theta + c + d \cos^2 \theta + e \cos \theta + f = 0$$

as posed in this question.

The straightforward approach does not work:

Assuming[a != 0 \[And] b != 0,
 Solve[a Sin[\[Theta]]^2 + b Sin[\[Theta]] + c + d Cos[\[Theta]]^2 + 
    e Cos[\[Theta]] + f == 0, \[Theta]]]

One can force "smart" substitutions, as given in the solution to the linked source problem. Is there a direct way to get the solution using Mathematica?

$\endgroup$
5
  • $\begingroup$ In practice I have found Weierstraß substitution to be least problematic in terms of branch-cut problems. Yes it's not direct, but really works in practice. So, I'd just go with what the MathSE answer suggests. $\endgroup$
    – Roman
    Nov 15, 2022 at 20:51
  • $\begingroup$ @Roman: Thanks. Even the Weierstra$\beta$ substitution is rather awkward in Mathematica. Is there really no other way? $\endgroup$ Nov 15, 2022 at 20:54
  • $\begingroup$ Solve[a Sin[θ]^2 + b Sin[θ] + c + d Cos[θ]^2 + e Cos[θ] + f == 0, θ, Quartics -> False] does the substitutions for you (albeit less elegantly than Weierstraß) but of course still ends up with arctangents of the roots of a quartic polynomial. It uses the full-quadrant form of ArcTan in order to avoid branch cuts. $\endgroup$
    – Roman
    Nov 15, 2022 at 20:59
  • 1
    $\begingroup$ (ß is written in LaTeX as \ss, not as \beta) en.wikipedia.org/wiki/ß $\endgroup$
    – Roman
    Nov 15, 2022 at 21:02
  • 1
    $\begingroup$ In the linked SE post, it is a and d that are non-zero, i.e., coefficients of the $\sin^2\theta$ and the $\cos^2\theta$ terms. $\endgroup$
    – Syed
    Nov 16, 2022 at 1:21

2 Answers 2

3
$\begingroup$

Mathematica has no trouble solving

eqn = a Sin[θ]^2 + b Sin[θ] + c + d Cos[θ]^2 + 
    e Cos[θ] + f == 0;

subs = {Sin[θ] -> sin, Cos[θ] -> cos};

solution = Solve[(eqn /. subs) && sin^2 + cos^2 == 1, {sin, cos}];

though the solution is rather large, and may not be useful to you.

$\endgroup$
1
  • $\begingroup$ Gee... that is a LARGE solution. Thanks, though ($+1$). $\endgroup$ Nov 15, 2022 at 22:17
1
$\begingroup$

I think Weirstaß-substitution isn't "awkward" and gives a clear direct solution:

Transforming the equation using Weirstaß-substitution \[Theta] -> 2 ArcTan[u\[Theta]] gives

eqW = a Sin[\[Theta]]^2 + b Sin[\[Theta]] + c + d Cos[\[Theta]]^2 + 
e Cos[\[Theta]] + f /. \[Theta] -> 2 ArcTan[u\[Theta]] // TrigExpand // Collect[#, {a, b, c, d, e, f}, Simplify] &     

$$ \frac{4 a \text{u$\theta $}^2}{\left(\text{u$\theta$}^2+1\right)^2}+\frac{2 b \text{u$\theta $}}{\text{u$\theta$}^2+1}+c+\frac{d \left(\text{u$\theta$}^2-1\right)^2}{\left(\text{u$\theta$}^2+1\right)^2}+\frac{e \left(1-\text{u$\theta$}^2\right)}{\text{u$\theta $}^2+1}+f $$

Mathematica

Solve[eqW == 0, u\[Theta], Reals] /. u\[Theta] -> Tan[\[Theta]/2];

finds four solutions in the form of Root objects

{Tan[\[Theta]/2] ->Root[c + d + e + f + 2 b #1 + (4 a + 2 c - 2 d + 2 f) #1^2 + 2 b #1^3 + (c + d - e + f) #1^4 &, 1]}

Solutions are lengthy.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.