Doubt related to formation of differential equation Question:

Find the order of the differential equation of $$y=C_1\sin^2x+C_2\cos 2x+C_3$$

I read in my book that the order of the differential equation is equal to the number of arbitrary constants but the answer given is $2$.
Attempt:
Here are two methods I tried:


*

*I calculated up to 3rd differential and obtained a differential equation.
$$\begin{align}
y&=C_1\sin^2x+C_2\cos2x+C_3\\
y'&=C_1\sin2x-2C_2\sin2x\\
y''&=2C_1\cos2x-4C_2\cos2x\\
y'''&=-4C_1\sin2x+8C_2\sin2x\\
&=-4(C_1\sin2x-2C_2\sin2x)\\
&=-4y'
\end{align}$$

*I differentiated both sides w.r.t. $x$ and then sent the $\sin2x$ term, which I was getting in RHS, to LHS and wrote $\frac1{\sin2x}$ as $\operatorname{cosec}2x$. Then I differentiated both sides again w.r.t. $x$. In this way, both $C_1$ and $C_2$ which remained after calculating 1st derivative become zero.
$$\begin{align}
y&=C_1\sin^2x+C_2\cos2x+C_3\\
y'&=C_1\sin2x-2C_2\sin2x\\
\operatorname{cosec}2xy'&=C_1-2C_2\\
2\operatorname{cosec}2x\cot2xy'+\operatorname{cosec}2xy''&=0\\
\implies2\cot2xy'+y''&=0
\end{align}$$
Which one is the correct method? If it's neither, what's the right method?
 A: I disagree with your book. The order of the DE must be 3. $\sin, \cos$, and $1$ are all linearly independent solutions, therefore they must be generated by a 3rd order DE.
A: Really this is a point of confusion. The book is right.

In general the order of a differential equation is the number of arbitrary constants in it.

Now just look at your function the number of arbitrary constants in it is really $2$. As \begin{align*}
y&=C_1\sin^2x+C_2 \cos 2x+C_3\\
&=C_1\sin^2x+C_2(1-2\sin^2x)+C_3\\
&=\sin^2x(C_1-2C_2)+(C_2+C_3)\\
&=A\sin^2x+B
\end{align*}
One thing more Whenever we want to know that whether our method is Correct simply we must check whether the given function is satisfying obtained differential equation or not. I Checked!! $y$ is satisfying the first differential equation you obtained and in second it should be $$y''-2\cot 2x y'=0.$$ Now Since in the second differential equation there are no arbitrary constants present so we can take it as the differential equation which characterises functions of the form $$y=C_1\sin^2x+C_2 \cos 2x+C_3$$   
A: The book is right that the order of a differential equation given its solution is the number of undetermined constants... except for a constant term. Why?
The differential equation this solution comes from is $y'' + 4y = -C_3$. Solving yields a family of solutions $y = A \cos 2x + B \sin 2x + C_3$, with parameters $A$ and $B$ dependent on the initial conditions. We only count these parameters - not the constant $C_3$, that comes from solving the inhomogeneous problem.
