I've encountered the following function while working on a project:

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

where a through e are all real non-zero numbers and $0 \leq \theta < 2 \pi$.

I know this function has at least two roots. For reasons I won't bore you with, finding the roots numerically isn't ideal for the project I'm working on.

Applying the tangent half-angle substitution described in this answer results in a fourth order polynomial, which is troublesome to find the roots of without numerical methods.

$$ 0 = (e-b)t^4 + (2a-2c) t^3 - 2et^2 + (2a+2c+4d)t + (b+e) $$

Is there a better non-numerical option for finding the roots?

  • 1
    $\begingroup$ I don't think the statement "I know this function has at least two roots" is true. For $a=b=c=d=1$ and $e=2$, the only root in $[0,2\pi)$ is equal to $3\pi/2$. $\endgroup$
    – jasnee
    Sep 29, 2021 at 22:14
  • $\begingroup$ @jasnee To clarify, there are additional constraints on a through e that I haven't detailed here. This root finding problem arose when I was trying to find the maximum and minimum of a function. $f(\theta)$ is part of that function's derivative. $\endgroup$
    – Jack Elsey
    Sep 29, 2021 at 22:23
  • 1
    $\begingroup$ First thought: the first two terms add to something of the form $A_1 \sin (\theta + \phi_1)$ where the amplitude $A$ and phase shift $\phi_1$ can be calculated with phasor diagrams (I think $A_1 = \sqrt{a^2 + b^2}$ and $\phi_1 = \arctan (b/a)$ if $a$ is positive), and the other three terms likewise add to something of the form $A_2 \sin (2\theta + \phi_2)$. Though I'm not sure this will help a lot: Wolfram Alpha nopes out of giving me closed-form solutions even to simple equations like $\sin \theta = 2 \sin (2\theta + \pi/4)$. $\endgroup$ Sep 29, 2021 at 22:24
  • $\begingroup$ @ConnorHarris haha, yes I ended up here after WolframAlpha showed me the door... $\endgroup$
    – Jack Elsey
    Sep 29, 2021 at 22:25
  • 1
    $\begingroup$ Is the original function any nicer (especially with the constraints on the constants)? There are sometimes non-calculus optimization methods. $\endgroup$ Sep 29, 2021 at 22:54

2 Answers 2


I don’t know whether this helps you at all, but you might consider making the substitution $y=\sin\theta$, $x=\cos\theta$, to get the equation $ay+bx+cxy+dy^2+ex^2=0$, since you’re looking for roots of $f$. The resulting curve in the plane is a conic of some shape or other, depending on the coefficients, and you want to intersect it with the circle $x^2+y^2=1$.

You thus have two conics, which intersect in four points in the complex projective plane, counting multiplicity, by Bézout’s Theorem. So the problem is, far as I can see, unavoidably quartic. Seems to me that with numerical inputs $\{a,b,c,d,e\}$ the only plausible method of finding the roots is something numerical, like Newton-Raphson. (There is a formula for the general quartic, but you Do Not want to try to use it.)

(And: I wouldn’t have gone via the tangent half-angle formulas, I would have just written $\cos\theta=\sqrt{1-\sin^2\theta\,}$ and manipulated the radicals away. You still get a quartic, likely not the same one.)




$$ ex^2 + dy^2 + 2\left( {\frac{c}{2}} \right)xy + bx + ay = f(x,y) = 0 $$ is a conic passing through the origin.


$$ \left\{ \begin{array}{l} x = \cos \theta \\ y = \sin \theta \\ \end{array} \right.\quad \Rightarrow \quad x^2 + y^2 = 1 $$ is a circle of unit radius with center at the origin


the zeros of your function $$ f(\theta) = 0 $$

correspond to the crossing of the conic with the circle, which may consist of none, two ("most probably"), or four points.

  • 1
    $\begingroup$ Three points is a possibility too, if the two conics are suitably tangent. $\endgroup$
    – Lubin
    Sep 29, 2021 at 22:37
  • 1
    $\begingroup$ @ Lubin It is "normal" practice then to consider that case as a $4$ points. $\endgroup$
    – G Cab
    Sep 29, 2021 at 22:43
  • $\begingroup$ Depending on whether the associated quartic touches the $x$-axis in two lobes, one, or none. Makes better sense, @GCab , I admit. $\endgroup$
    – Lubin
    Sep 30, 2021 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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