# Two different results on solving a differential equation by variation of parameters V.S undetermined coefficients

I'm trying to solve:

$$y'' -4xy' + (4x^2 -1)y = -3e^{x^2} \sin(2x)$$

Which has a general form of

$$y'' + P(x) y' + Q(x) = R(x)$$

I reduced it to the normal form by using the substitution $$y = u e^{ - \frac{1}{2} \int P(x)} dx$$

$$u'' + I(x) u = S(x)$$

Where $$I(x) = Q - \frac {p'}{2} - \frac {p^2}{4}$$

and $$S(x) = R(x) e^{ \frac{1}{2} \int P(x) dx}$$

I end up with:

$$u'' + u = -3 \sin(2x)$$

I solve first for the complementary function when its homogeneous

$$u_{C.F} = A \cos(x) + B \sin(x)$$

Then to solve for the particular solution, I first decided to use variation of parameters, then,

$$u_{P.I} = v_1y_1 + v_2y_2$$

Where $$y1$$ and $$y2$$ are the solutions to the homogeneous equation, I let $$y1 = \cos(x)$$ and $$y2 = \sin(x)$$

I compute the Wronskian of both functions since they are linearly independent solutions, $$W(y1(x),y2(x) = \left|\begin{matrix}y1 & y2 \\ y1' & y2' \end{matrix}\right| = \left|\begin{matrix}\cos(x) & \sin(x) \\ - \sin(x) & \cos(x) \end{matrix}\right| = 1$$

$$(v_2)' = \frac {-y_2 S(x)}{W} = \frac {- \sin(x) (-3 \sin(2x))}{1} = 6 \sin^2(x) \cos(x)$$

$$(v_1)' = \frac {y_1 S(x)}{W} = \frac { \cos(x) (-3 \sin(2x))}{1} = -6 \cos^2(x) \sin(x)$$

Integrating $$v_1$$ and $$v_2$$ I get,

$$v_1 = 2 \cos^3(x)$$ , $$v_2 = 2sin^3(x)$$

Substituting in $$u_{P.I} = v_1y_1 + v_2y_2$$ ,

$$u_{P.I} = 2 [ \cos^4(x) + \sin^4(x)]$$

So to get $$y_{P.I}$$ , $$y_{P.I} = u_{P.I} e^{ - \frac{1}{2} \int P(x)} dx$$

Therefore, $$y_{P.I} = 2e^{x^2} [ \cos^4(x) + \sin^4(x) ]$$ <------

This is a solution using variation of parameters, now when I try to do it using undetermined coefficients:

$$u'' + u = -3 \sin(2x)$$

Let $$u_{P.I} = A \sin(2x) + B \cos(2x)$$

Skipping some steps, we arrive that $$A = 1$$ , and $$B = 0$$

Then the solution is \$u_{P.I} = \sin(2x)

Therefore, $$y_{P.I} = e^{x^2} \sin(2x)$$ <------

These are two different particular solutions, where's the problem?

Ok, I got it, when calculating $$(v_2)'$$ and $$(v_1)'$$ , they should be:

$$(v_2)' = \frac {y_1 S(x)}{W} = \frac { \cos(x) (-3 \sin(2x))}{1} = -6 \cos^2(x) \sin(x)$$

$$(v_1)' = \frac {-y_2 S(x)}{W} = \frac { -\sin(x) (-3 \sin(2x))}{1} = 6 \sin^2(x) \cos(x)$$

Then,

$$v_2 = 2 \ cos^3(x)$$ and $$v_1 = 2 \sin^3(x)$$

Then $$u_{P.I} = v_1 y_1 + v_2 y_2 = 2 \sin^3(x) \cos(x) 2 \ cos^3(x) \sin(x) = 2 \sin(x) \cos(x) [ \cos^2(x) + \sin^2(x) ] = 2 \sin(x) \cos(x) = \sin(2x)$$

Which is identical to the undetermined coefficients method.