# Differential equation with a constant in it

Solve $$y'' + s^2y = b \cos sx$$

where $s$ and $b$ are constants. I have tried undetermined coefficients, but it makes such a mess that I keep getting lost, I also tried variation of parameters. Really my issue is staying organized enough to get the solution, my solutions are always just a little off from the book.

I have solved the complementary homogenous equation, this gave me a solution with $\cos{sx}$ in it... So that's off limits in the particular solution. I looked for a solution in $x \sin{sx}$ and $x \cos{sx}$, but as I said, it was a mess.

I wonder if I'm just going about it all wrong.

Related to this, why will variation of parameters sometimes produce a term that is a solution to the homogenous case?

Thanks

-
Please disambiguate this equation with parentheses and clarification about what derivate $y''$ is supposed to be. (It may be obvious from the context, but it's still an unneccessary risk of confusion and also additional work of guessing which variant is the right one.) –  leftaroundabout Jul 1 '11 at 15:23
Related: math.stackexchange.com/questions/24575/…. See Sivaram's answer there. –  Aryabhata Jul 1 '11 at 16:09
@Noteventhetutorknows Please see my edited answer below on the method of variation or parameteres. –  user38268 Jul 2 '11 at 5:06

The method of undetermined coefficients is a tricky one, but I refer you to Morris and Tenenbaum's Ordinary Differential Equations. It tells you when and how to make a good ansatz to a problem like that. There are conditions like (I don't remember off the top of my head) if the R.H.S. $f(x)$ does not appear in the complementary function, then you make.... but if it does, then you need to consider a linear combination like say $(ax+b)(\cos(x) + \sin(x))$ and all its linearly independent derivatives. However, a sure fire way to get an answer is using the operator method (Please see the textbook).

$$(D^2 + s^2)[y] = b\cos(sx).$$

You have already told us that the solution to the homogeneous problem is $y = A\cos(sx ) + B\sin(sx)$. To find a particular solution to the inhomogeneous problem, we solve the related problem

$$(D^2 + s^2)[y] = be^{isx}$$

and take its real part. For details on this operator method, please see the textbook I mentioned above.

So there according to the reference, your solution can be found by writing

$$y = \frac{1}{D^2 + s^2}[be^{isx}],$$

and then use the so called shift formula given in the reference above, namely you can take the exponential out of the operator, but must replace $D$ with $(D + is)$. The operator here is $\displaystyle\frac{1}{D^2 + s^2}$ that operates on the right hand side $be^{isx}$. So

\begin{align*} y &= e^{isx}\frac{1}{(D + is)^2 + s^2}[b] \\ &= e^{isx}\frac{1}{D^2 + 2iD}[b] \end{align*}

I'll leave the rest for you to think about. With this method, you can treat an operator as if it were a "number", so that

$$\frac{1}{1-D} = 1 + D + D^2 + \cdots.$$

The only difference is that one does not talk of $|D|\lt1$ here (I know nothing about functional analysis, so I don't know what it means for a linear operator to be bounded).

Next step: Notice that the operator is operating on a constant, so when an infinite series like the above operates on $b$, it must terminate.

To answer your question why sometimes solutions to the homogeneous problem are included inside the particular solution, its because when constructing the one-sided green's function (this is the same as the method of variation of parameters here) you exclude the arbitrary constants in front of the two linearly independent solutions to the homogeneous problem.

Attention Noteventhetutorknows:

The differential equation in self-adjoint form

$L[y] = -(p(x)y')'+ q(x)y = f(x)$

with initial conditions $y(x_0) = y'(x_0) = 0$ has particular solution

$y(x) = \int_{t_0}^{t} G(x,\tau) f(\tau) d\tau$,

where $G(x, \tau)$ is the one sided green's function given by

$G(x, \tau) = \begin{cases} \frac{y_1(x)y_2(\tau) - y_2(x)y_1(\tau)}{W(\tau)}, &\text{if} \quad x \geq \tau \\ 0,& \text{if} \quad x < \tau. \end{cases}$

-
I like the way that the factor $x$ emerges from applying $\frac{1}{D}$, but don't you need a constant of integration. –  Mark Bennet Jul 1 '11 at 15:55
Ben: I tried to fix some formatting and linking problems in your post, I hope I wasn't too intrusive. There still remains the point Mark made. –  t.b. Jul 1 '11 at 16:06
@Mark Bennet What do you mean about the constant of integration? –  user38268 Jul 1 '11 at 17:08
@Theo Buehler I looked at the edits you made and there is text in there that is essentially the same but some in green and some in red. What's the difference? –  user38268 Jul 1 '11 at 17:09
The green stuff was added, the red stuff deleted. It tends to display too much in both directions. –  t.b. Jul 1 '11 at 17:12

You need to differentiate eg $y = Ax\cos sx$ twice using the chain rule.

So $y' = A\cos sx - Asx \sin sx$

And $y'' = -2As \sin sx - As^2x\cos sx$

Then $y'' + s^2y = -2As \sin sx$

But you need $\cos sx$ - and I'm sure you can see how to do that now.

NOTE: Because the equation is linear, if the expressions get messy you can deal with the sin and cos terms from $y= Ax\sin sx + Bx\cos sx$ separately and get the right linear combination at the end. Sometimes it can be easier to convert everything to exponential functions.

-
Bennet Please see my answer below on solving a related problem and taking its real part. –  user38268 Jul 1 '11 at 15:33
@D Lim - Indeed. –  Mark Bennet Jul 1 '11 at 15:48

You might find the Second Order Linear Equations sections of my differential equations notes helpful. In this case you start with the complex version of your equation, $P(D) y = b e^{isx}$ where $P(D) = D^2 + s^2 = (D + i s)(D - i s)$, $D$ being the derivative operator. Here $is$ is one of the two roots of $P$: we write $y = e^{isx} u$, and by the Exponential Shift Theorem $P(D) e^{isx} u = e^{isx} P(D + is) u = e^{isx} (D + 2 i s) D u$. With $v = D u$ we now want $(D + 2 i s) v = b$. That has a constant solution $v = \frac{b}{2is} = \frac{-ib}{2s}$. Integrating, $u = \frac{-ib x}{2s}$ (we can disregard the arbitrary constant, which leads to a solution of the homogeneous equation). So $y = \frac{-ibx}{2s} e^{isx}$ is a solution of $y'' + s^2 y = b e^{isx}$. Writing $e^{isx} = \cos(sx) + i \sin(sx)$ and taking the real part, $y = \frac{bx}{2s} \sin(sx)$ is a solution of your differential equation.

-
@Noteventhetutorknows Please see en.wikipedia.org/wiki/Shift_theorem. Essentially what Robert and I have said is the same thing. –  user38268 Jul 2 '11 at 0:51
All this is, of course, assuming $s \ne 0$. I'll leave the $s=0$ case up to you. –  Robert Israel Jul 3 '11 at 7:42

Here is an ad-hoc method to solve this (which was derived from my answer here: What is the quickest way to solve this 2nd Order Linear ODE?)

First notice that

$$(y' \cos sx + s y \sin sx)' = y''\cos sx - sy' \sin x + s y' \sin sx + s^2 y \cos sx = \cos sx(y'' + s^2 y)$$

Thus $\displaystyle (y' \cos sx + s y \sin sx) = \int b\cos^2 sx + A$

Now $\displaystyle (y' \cos sx + s y \sin sx) = (\frac{y}{\cos sx})' \cos^2 sx$

Thus $$\frac{y}{\cos sx} = \int \sec^2 sx (\int b \cos^2 sx + A) + B$$

For a more general method, you can also try Laplace Transform (it might be easier to bring in complex numbers first, as in D Lim's answer).

The method in D Lim's answer is what I would recommend reading first, though.

-