Solving the 2nd order linear differential equation in $LC$ oscillator I was reading Halliday and Resnick and it had given the differential equation
$$L\frac{d^2q}{dt^2} +\frac{1}{C}q=0$$
Now when I attempted to solve this equation, I got $q=Q(\cos \omega t+i\sin \omega t)$ whereas the equation given in the book is $q=Q\cos(\omega t+\phi$). Now I don't understand whether I have made a mistake or my equation is an alternative form. Any help would be appreciated.
 A: There's a small problem with the answer you obtained, but apart from that, both the answers are equivalent. Your answer should rather be something like: $$q(t) = A \cos{\omega t} +i B \sin{\omega t}.$$ Since I don't have your working, I can't be sure what's wrong with it. However, since this is the solution to a second order differential equation, it is clear that there should be two arbitrary constants which are set by the initial conditions; in this case these constants are $A$ and $B$. Note also that since you have chosen to use complex numbers, $A$ and $B$ don't need to be real, necessarily.
The solution in the book is just another way of writing this same solution. To see that, just expand it out, and compare the coefficients of $\sin{\omega t}$ and $\cos{\omega t}$: \begin{aligned}q(t) &= Q\cos{(\omega t + \phi)},\\ &= (Q \cos{\phi}) \cos{\omega t} - (Q\sin{\phi})\sin{\omega t},\end{aligned}
where I've just used the trigonometric identity $\cos{(A+B)} = \cos A \cos B - \sin{A}\sin{B}$. Since the $\sin$ and $\cos$ functions are linearly independent (i.e., one cannot be written as a multiple of the other for all values of $t$), you can see that if you chose \begin{aligned}A &= Q\cos{\phi},\\ B &= iQ\sin{\phi},\end{aligned}
both your solutions are essentially the same. The values of $Q$ and $\phi$ are set by the initial conditions, just like the values of $A$ and $B$. If you wish, you could verify this explicitly for some initial conditions (say, the system starts off with all the capacitor fully charged, and allowed to discharge, or something like that) and you'd see that they both give the same result.
