# Solve \frac{dy}{dx} + 2xy = x subject to y(0) = a

## Question:

Solve {eq}\dfrac{dy}{dx} + 2xy = x {/eq} subject to {eq}y(0) = a {/eq}

## Separable Differential Equation

Separable differential equations are equations where the variables can be separated in the form

{eq}f(y) \;dy = g(x) \;dx {/eq}

To solve such differential equation, simply integrate both sides then write the equation as {eq}y {/eq} in terms of {eq}x {/eq}. If an initial condition is given, solve for the arbitrary constant using the condition.

## Answer and Explanation:

We can manipulate the function to become a separable differential equation.

{eq}\dfrac{dy}{dx} + 2xy = x \\ \dfrac{dy}{dx} = x - 2xy \\ \dfrac{dy}{dx} = -x(-1 + 2y) \\ \displaystyle \left ( \frac{1}{-1+2y} \right )\dfrac{dy}{dx} = -x(-1 + 2y)\left ( \frac{1}{-1+2y} \right ) \\ \displaystyle \left ( \frac{1}{-1+2y} \right )\dfrac{dy}{dx} = -x \\ \displaystyle \left ( \frac{1}{-1+2y} \right )dy = - x\;dx {/eq}

Integrate both sides of the equation.

{eq}\displaystyle \int \left ( \frac{1}{-1+2y} \right )dy = \int -x\;dx \\ \displaystyle \int \left ( \frac{1}{2y-1} \right )dy = \int -x\;dx {/eq}

For the left side of the equation, we can perform a substitution. Let

{eq}u = 2y-1 \\ du = 2\;dy \rightarrow dy = \dfrac{du}{2} {/eq}

The integral becomes

{eq}\displaystyle \int \left ( \frac{1}{u} \right )\left ( \dfrac{du}{2} \right ) = \int -x\;dx \\ \displaystyle \int \left ( \frac{1}{2u} \right )du = \int -x\;dx {/eq}

Take out the constant.

{eq}\displaystyle \frac{1}{2}\int \frac{1}{u}\;du = -\int x\;dx \\ \displaystyle \frac{1}{2}(\ln|u|) = -\int x\;dx {/eq}

Substitute back the value of {eq}u {/eq}.

{eq}\displaystyle \frac{1}{2}\ln(2y-1) = -\int x\;dx {/eq}

For the right side, we can apply power rule for integrals: {eq}\int x^n \;dx = \frac{x^{n+1}}{n+1} {/eq}.

{eq}\displaystyle \frac{1}{2}\ln(2y-1) = -\frac{x^{1+1}}{1+1} \\ \displaystyle \frac{1}{2}\ln(2y-1) = -\frac{x^{2}}{2} \\ \displaystyle 2\left (\frac{1}{2}\ln(2y-1) = -\frac{x^{2}}{2} \right )2 \\ \displaystyle \ln(2y-1) = -x^{2} {/eq}

Add a constant of integration.

{eq}\displaystyle \ln(2y-1) = -x^{2} + C \\ \displaystyle e^{\ln(2y-1)} = e^{-x^{2} + C} \\ \displaystyle (2y-1) = e^{-x^{2} + C} \\ \displaystyle 2y = e^{-x^{2} + C} + 1 \\ \displaystyle y = \frac{e^{-x^{2} + C} + 1}{2} \\ \displaystyle y = \frac{e^{-x^{2} + C}}{2} + \frac{1}{2} \\ \displaystyle y = \frac{e^{-x^{2}}\cdot e^C}{2} + \frac{1}{2} {/eq}

Since {eq}C {/eq} is just an arbitrary constant, we know that {eq}e^C {/eq} is a constant value and let's represent as {eq}K {/eq}.

{eq}\displaystyle y = \frac{Ke^{-x^{2}}}{2} + \frac{1}{2} {/eq}

To solve the value of the constant, apply the initial condition given, {eq}y(0) = a {/eq}.

{eq}\displaystyle y(0) = \frac{Ke^{-(0)^{2}}}{2} + \frac{1}{2} = a \\ \displaystyle \frac{Ke^{0}}{2} + \frac{1}{2} = a \\ \displaystyle \frac{K(1)}{2} = a - \frac{1}{2} \\ \displaystyle \frac{K}{2} = a - \frac{1}{2} \\ \displaystyle K = 2a - 1 {/eq}

The solution is therefore:

{eq}\displaystyle \boldsymbol{y(x) = \frac{(2a-1)e^{-x^{2}}}{2} + \frac{1}{2}} {/eq}

#### Learn more about this topic:

from GRE Math: Study Guide & Test Prep

Chapter 16 / Lesson 1