# Solution of $y''+4y=\cos^2t$

I'm trying to find the solution, which is supposed to be

$y(t)=c_2\sin(2t)+c_1\cos(2t)+\frac{t\sin(2t)}{8}+\frac{\cos^2(t)}{4}$,

but I'm doing something wrong along the way and I can't figure out what I did. I was hoping someone would be able to find my mistake for me. I'll show what I've gotten:

First I got the complementary solution $y_c(t)=c_1\cos(2x)+c_2\cos(2x)$

I then used the particular solution $y_p=A+B\cos(2t)+C\sin(2t)$ - I'm guessing this is where my error occurs, but I don't see what's wrong with it.

I derived it two times and got $y_p''=-4B\cos2t-4C\sin(2t)$

I plugged it into the original equation (assuming $\cos^2t$ is $\frac{1}{2}+\frac{\cos(2x)}{2}$) and then tried to solve the problem, at which point I found myself running in circles:

$\sin2t(-4C-4C)+\cos2t(-4B+4B)+4A=\frac{1}{2}+\frac{\cos(2x)}{2}$.

Can anyone help me find my mistake(s)? Thanks a lot.

• $e^{\pm 2x}$ is not a solution to $y''+4y=0$. – njguliyev Oct 26 '13 at 22:35
• Thank you. I got $y_c(t)=c_1cos(2x)+c_2cos(2x)$ the second time around, I will put it into my question. I'm pretty sure I'm still doing something else wrong though. – user91971 Oct 26 '13 at 22:39
• The characteristic equation associated with $y'' + 4y = 0$ is $\lambda^2 + 4 = 0$. Notice your inhomogeneous term $\cos^2 t$ can be rewritten as $\frac12 (1+ \cos(2t)) = \frac14 ( 2 + e^{2it} + e^{-2it} )$ and contains Fourier components of angular frequency $0, \pm 2i$. Since $\pm 2i$ are simple roots of the characteristic equation, the generic form of the particular solution has the form $a + \color{red}{t} (b \cos(2t) + c\sin(2t))$ instead. – achille hui Oct 26 '13 at 22:50

You figured out the issue with:

$$y_c(t) = c_1 \cos 2t + c_2 \sin 2t$$

For the particular solution, some care is needed given the homogeneous (complementary) solution. We expand the $\cos^2 2t$ term as:

$$\cos^2 2t = \dfrac{1}{2}\left(1 +\cos 2t\right)$$

Now, we notice that this has a common term with the homogeneous term, so we multiply the particular solution by $t$ to account for that. Thus, we choose a particular solution as:

$$y_p(t) = a + b~ t \cos 2t + c~ t \sin 2t$$

Now, substitute and solve for $a$, $b$ and $c$.

You should get:

$$a = \dfrac{1}{8}, b = 0, c = \dfrac{1}{8}$$

$$y(t) = y_c(t) + y_p(t)$$

• Thank you. I redid my work several times and got $a$ and $b$ correct, but I keep getting all sorts of weird numbers for $c$. I'll try to redo my problem a few more times. If I still can't get $c$ to work out, I might ask a question about some of the nitty-gritty calculations if that's all right with you. – user91971 Oct 26 '13 at 23:15
• No problem! Give a go and if you get stuck, give a yell! – Amzoti Oct 26 '13 at 23:18
• Very well written and +1 for the encouraging spirit! – Namaste Oct 27 '13 at 0:41

The complementary solution is $$y_c(t) = c_1\cos(2t) + c_2\sin(2t).$$ Notice that $t\mapsto \cos^2(t)$ is in the linear span of this solution. What do you do in those cases?

• Thanks, I have corrected that error. However, I know I've botched up somewhere else too. In regards to your question, do you mean that I need to set my $y_p=A+Btcos2t+Ctcos2t$? I notice that I have duplication now because I made a mistake in my complementary solution. – user91971 Oct 26 '13 at 22:40
• Give it a whirl. – ncmathsadist Oct 26 '13 at 22:45
• I redid the problem and got $B=0$, $C=\frac{1}{4}$, and $A=\frac{1}{8}$. Is this correct? If not, I'll go back and review my work and post what I did if I can't find where I went wrong. Actually, this looks wrong. I'll go rework my problem. – user91971 Oct 26 '13 at 22:55
• Found out where I went wrong. Thank you for your help! – user91971 Oct 26 '13 at 23:28

$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\dd}{{\rm d}}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\ic}{{\rm i}}% \newcommand{\imp}{\Longrightarrow}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert #1 \right\vert}% \newcommand{\yy}{\Longleftrightarrow}$ $\ds{y'' + 4y = \cos^{2}t:\ {\large ?}}$

Let's define $\mu \equiv y' + 2y\ic$ such that $$\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! \cos^{2}\pars{t} = y'' + 4y = \pars{\mu'' - 2y'\ic} + 4\,{\mu - y' \over 2\ic} = \mu' -2\mu\ic \quad\imp\quad \mu' -2\mu\ic = \cos^{2}\pars{t} \tag{1}$$ $$\mbox{Notice that}\quad y = {1 \over 2}\,\Im\mu \tag{2}$$

Multiply both members of the last equation in $\pars{1}$ by the factor $\expo{-2\ic t}$: $$\expo{-2\ic t}\mu' -2\mu\expo{-2\ic t}\ic = \expo{-2\ic t}\cos^{2}\pars{t} \quad\imp\quad \totald{\pars{\expo{-2\ic t}\mu}}{t} = \expo{-2\ic t}\cos^{2}\pars{t}$$

$$\expo{-2\ic t}\mu = \int\expo{-2\ic t}\cos^{2}\pars{t}\,\dd t + A \quad\mbox{where}\quad A \in {\mathbb C}\ \mbox{is a}\ {\it\mbox{constant}}. \tag{3}$$ Also \begin{align} \int\expo{-2\ic t}\cos^{2}\pars{t}\,\dd t &= \int\expo{-2\ic t}\,{1 + \cos\pars{2t} \over 2}\,\dd t = {1 \over 2}\bracks{% \int\expo{-2\ic t}\,\dd t + {1 \over 2}\pars{1 + \int\expo{-4\ic t}\,\dd t}} \\[3mm]&= {1 \over 4}\,\ic\expo{-2\ic t} + {1 \over 4}\,t + {1 \over 16}\,\ic\expo{-4\ic t} \end{align} By replacing this integration in $\pars{3}$ we get: $$\mu = {1 \over 4}\ic + {1 \over 4}\,t\expo{2it} + {1 \over 16}\,\ic\expo{-2\ic t} + A\expo{2it}$$ Then $\pars{~\mbox{see Eq.}\ \pars{2}~}$ $$y = {1 \over 8} + {1 \over 8}\,t\sin\pars{2t} + {1 \over 32}\,\cos\pars{2t} + {1 \over 2}\,\Im\bracks{A\expo{2it}}$$ Let's write $A = B/4 + 2\pars{C - 1/32}\,\ic$ where $B$ and $C$ are constants $\pars{~B, C \in {\mathbb R}~}$: $$y = {1 \over 8} + {1 \over 8}\,t\sin\pars{2t} + {1 \over 32}\,\cos\pars{2t} + {1 \over 8}\,B\sin\pars{2t} + \pars{C - {1 \over 32}}\cos\pars{2t}$$

\begin{align} & \\[1cm] \\ {\large y\pars{t}} &{\large = {1 \over 8} + {1 \over 8}\pars{t + B}\sin\pars{2t} + C\cos\pars{2t}} \\[3mm]& {\large B\ \mbox{and}\ C\ \mbox{are determined by the initial conditions.}} \end{align} Let's check it: \begin{align} y'\pars{t} &= {1 \over 8}\,\sin\pars{2t} + {1 \over 4}\pars{t + B}\cos\pars{2t} - 2C\sin\pars{2t} \\[3mm] y''\pars{t} &= {1 \over 4}\,\cos\pars{2t} + {1 \over 4}\cos\pars{2t} - {1 \over 2}\pars{t + B}\sin\pars{2t} - 4C\cos\pars{2t} \\ {\large y''\pars{t} + 4y\pars{t}} &= {1 \over 4}\,\cos\pars{2t} + {1 \over 4}\cos\pars{2t} + {1 \over 2} = {1 \over 2}\bracks{1 + \cos\pars{2t}} = {\large\cos^{2}\pars{t}} \end{align}