# 2nd Order ODE (Variation of Parameter)

I am given the equation $$y''+y = x\cos x - \cos x$$ with initial values of $$y(0)=1, y'(0)= 1/4,$$and I believe this needs to be solved using the method of variation of parameters, though I'm unsure, because after solving the characteristic equation $$m^2+1 =0$$ $$m = -i, i$$ I'm left with $$y_h = C_1\sin x + C_2\cos x,$$and I'm not sure where to move forward from there. I tried taking the Wronskian ($$W=1$$), and finding $$W_1, W_2$$ but I'm getting stuck on extremely long integrals to find $$u_1, u_2$$.

Any help for next steps or an alternative method would be greatly appreciated.

• You could also use the methods of undetermined coefficients; have you seen this? Apr 2, 2019 at 8:29
• @Robert Schwartz. See the continuation of your solving (with the Wronskian) in my answer below. Apr 2, 2019 at 10:40

I believe this needs to be solved using the method of variation of parameters, though I'm unsure, (...) but I'm getting stuck on extremely long integrals

Any help for next steps or an alternative method would be greatly appreciated.

Alternatively, using the method of undetermined coefficients, you would propose a particular solution of the form: $$y_p=(Ax+B)\sin x + (Cx+D)\cos x$$ but since (a part of) this solution is already contained in the homogeneous solution, you alter this to: \begin{align}y_p & =(Ax+B)\color{red}{x}\sin x + (Cx+D)\color{red}{x}\cos x \\ & =(Ax^2+Bx)\sin x + (Cx^2+Dx)\cos x \end{align} Substitution of this proposed particular solution into the differential equation leads to a linear system of four equations in the four unknowns $$A,B,C,D$$; no messy integrals.

• Once I have the particular solution $y_p$, what should my next steps be for solving the equation with the initial values? Apr 2, 2019 at 9:01
• Use the initial values to determine the $C_1$ and $C_2$ of the homogeneous solution; it doesn't matter how you found a particular solution. Apr 2, 2019 at 9:03
• I ended up solving for $y_g=y_h+y_p=(1/4x-1/2)xsinx-(1/4)xcosx+cosx+(1/4)sinx$ Apr 2, 2019 at 9:23
• In the part of the particular solution, you should get $\tfrac{1}{4}x\cos x$ (without the minus) and that would cause the $\tfrac{1}{4}\sin x$ to disappear. Apr 2, 2019 at 9:27

$$y ″ + y = (x-1)\cos(x)$$

They are several methods to solve it.

The method of variation of parameters (involving Wronskian) is not the simplest in the present case. Nevertheless, since it is the method that the OP want, we will use this method.

Solving the associated homogeneous equation $$y ″ + y = 0$$ leads to the two linearly independent solutions $$u_1=\sin(x)$$ and $$u_2=\cos(x)$$ .

The Wronskian of these two functions is $$W=\left|\left|\begin{matrix} \sin(x) & \cos(x) \\ \cos(x) & -\sin(x) \\ \end{matrix}\right|\right|=-1$$ The solution of the non-homogeneous ODE is on the form : $$y(x)=A(x)u_1(x)+B(x)u_2(x)$$ With $$R(x)=(x-1)\cos(x)$$ the non-homogeneous term. $$A(x)=-\int \frac{1}{W}u_2(x) R(x)dx=\int (x-1)\cos^2(x)dx$$ $$B(x)=\int \frac{1}{W}u_1(x) R(x)dx=-\int (x-1)\cos(x)\sin(x)dx$$ $$A(x)= \frac14 x^2-\frac12 x-\frac12(x-1)\sin(x)\cos(x)+\frac14 \cos^2(x)+C_1$$ $$B(x)=\frac14 x-\frac12(x-1)\cos^2(x)-\frac14\sin(x)\cos(x)+C_2$$ $$y(x)=\left(\frac14 x^2-\frac12 x-\frac12(x-1)\sin(x)\cos(x)+\frac14 \cos^2(x)+C_1 \right)\sin(x)+\left(\frac14 x-\frac12(x-1)\cos^2(x)-\frac14\sin(x)\cos(x)+C_2 \right)\cos(x)$$

After simplification : $$\boxed{y(x)=C_1\sin(x)+C'_2\cos(x)+\frac14 x^2\sin(x)-\frac12 x\sin(x)+\frac14 x\cos(x)}$$ $$C'_2=C_2-\frac12$$

Your equation is of the form $$(D^2+1) y = x \cos x - \cos x$$. If you apply the differential operator $$(D^2+1)^2$$, you get the equation $$(D^2+1)^3 y = 0$$, that has the solution $$y = (ax^2+bx+c) \cos x + (dx^2+e x + f)\sin x$$. This indicates that a particular solution can take the form $$y_p = (ax^2+bx) \cos x + (d x^2 + e x)\sin x$$. Plugging the function into the equation you can compute the coefficients and get $$y_p(x)=\frac 14 x \cos x + (\frac 14 x^2-\frac 12 x) \sin x$$

The general solution is then given by

$$y(x)=y_h(x)+y_p(x)$$

We have that

$$y = y_h + y_p$$

with

$$y_h = c_1 \cos x+c_2 \sin x$$

Making $$y_p = c_1(x) \cos x+c_2(x) \sin x$$ and substituting into the particular we have

$$(c_1''(x)+2c_2'(x)-x+1)\cos x+(c_2''(x)-2c_1'(x))\sin x = 0$$

then choosing $$c_1(x), c_2(x)$$ such that

$$c_1''(x)+2c_2'(x)-x+1 = 0\\ c_2''(x)-2c_1'(x) = 0$$

and after solving for $$c_1(x), c_2(x)$$ we have

$$y = (c_1 + c_1(x))\cos x+(c_2 + c_2(x))\sin x$$

NOTE

This kind of problem can be easily solved with the help of the Laplace transform.

Trying to find the solution by variation of parameters one proceeds with the parametrization of the general solution as $$y(x)=c_1(x)\cos(x)+c_2(x)\sin(x).$$ In the first derivative one fixes the relation between $$c_1$$ and $$c_2$$ by demanding

$$c_1'(x)\cos(x)+c_2'(x)\sin(x)=0$$

The remaining terms of the first derivative are $$y'(x)=-c_1(x)\sin(x)+c_2(x)\cos(x).$$ Then insert the second derivative into the ODE which gives

$$-c_1'(x)\sin(x)+c_2'(x)\cos(x)=(x-1)\cos(x).$$

Now isolating the derivatives can be done via the trigonometric identity $$\cos^2(x)+\sin^2(x)=1$$ to find \begin{align} c_1'(x)&=-(x-1)\cos(x)\sin(x),\\ c_2'(x)&=(x-1)\cos^2(x). \end{align} This can now be integrated via the double-angle identities and partial integration.

Another way to look at this is to write the linear system in matrix form $$\pmatrix{\cos x&\sin x\\-\sin x&\cos x} \pmatrix{c_1'(x)\\c_2'(x)} = \pmatrix{0\\(x-1)\cos x}$$ where the system matrix can be identified with the Wronski-matrix of the fundamental system $$(\cos x, \sin x)$$. The Wronskian determinant is $$1$$, so that solving the system proceeds by multiplying with the transpose matrix, giving the same derivatives.