# Calculus

## Solving Differential Equations (Separable and FOLDE)

Differential equations can be solved in different ways depending on their classification. Not all differential equations will have a nice solution. However, using these techniques, we can solve for solutions to certain types of differential equations. On this page, we will look at solving separable and First Order Linear Differential Equations (FOLDEs). You may not encounter these in your course, but they can give you a good idea of how to approach solving differential equations and some techniques used.

## Separable Differential Equations

Recall that a separable differential equation is of the form $$\frac{dy}{dx} = f(x)g(y)$$. The steps to solve these types of differential equations are as follows:

1. Move all the $$y$$ terms (including $$dy$$) to one side and the $$x$$ terms (including $$dx$$) to the other.
2. Integrate both sides
3. Simplify to isolate $$y$$ and find the explicit solution

## Examples

1. Solve this separable differential equation: $$\frac{dy}{dx} = 6xy$$

Solution

First, move all the $$y$$ terms to one side and the $$x$$ terms to the other side:

\begin{align} \frac{dy}{dx}&=6xy \\ \\ \implies \qquad \frac{dy}{ydx} &= 6x \\ \\ \implies \qquad \frac{1}{y}dy &= 6x \, dx \end{align}

Now, we can integrate both sides and solve the integrals:

\begin{align} \int \frac{1}{y}\, dy &= \int 6x\, dx \\ \\ \implies \qquad ln|y| + D &= 3x^2 + E \qquad \text{where} \; D, E \; \text{are constants} \end{align}

Finally, we can isolate for y to find the explicit solution to the differential equation:

\begin{align} ln|y| + D &= 3x^2 + E \\ \\ \implies \qquad ln|y| &= 3x^2 + E - D \\ \\ \implies \qquad e^{ln|y|} &= e^{3x^2 + E-D} \\ \\ \implies \qquad |y| &= e^{3x^2 + E-D} \\ \\ \implies \qquad y &= \pm e^{2x^2 + E-D} \end{align}

Now that we have isolated for $$y$$, we can simplify the equation:

\begin{align} y &= \pm e^{3x^2 + E-D} \\ \\ \implies \qquad y &= \pm e^{3x^2} e^{E-D} \end{align}

Since $$\pm e^{E-D}$$ is a constant we can let this equal $$C$$. Thus, our general solution is $$y=Ce^{3x^2}$$.

We can verify this solution by plugging it back into our equation:

\begin{align} y' &= (6x)(Ce^{3x^2}) \\ &= 6xy \qquad \qquad \; \text{as required.} \end {align}

Note: Some textbooks might ignore the absolute value in the solution of $$\int \frac{1}{y}\,dy$$. Note that this doesn't change our final answer because the $$\pm$$ gets absorbed in the constant $$C$$. Either solution is correct.

2. Solve the differential equation: $$y' = \frac{2}{y}$$

Solution

When our differential equation is in the form of $$y'$$, it's best to rewrite it in Leibniz notation. Thus, we have $$\frac{dy}{dx} = \frac{2}{y}$$. Now we can rearrange our equation accordingly:

$$\frac{dy}{dx} = \frac{2}{y} \implies y\,dy = 2 dx$$

Next, we integrate both sides:

$$\int y\,dy = \int 2\,dx \implies \frac{1}{2}y^2 + D = 2x + E$$

Now, isolate for $$y$$ and simplify:

$$\frac{1}{2}y^2 + D = 2x + E \implies y^2 + 2D = 4x + 2E \implies y^2 = 4x+2E - 2D \implies y = \pm \sqrt{4x+2E-2D}$$

Let $$2E-2D = C$$ to get the explicit solution $$y = \pm \sqrt{4x+C}$$. Verify that this solution is correct by substituting $$y, y'$$ into the original differential equation.

## Initial Conditions

We have seen that the solution to a differential equation gives infinite solutions based on the value of our constant, $$C$$. In some cases, however, we might be looking for a specific solution. We can do this by introducing one or multiple initial conditions. Initial conditions are conditions such as $$y(x_0) = y_0$$ applied to differential equations and tell you how to find a specific value for $$C$$

Example

Solve $$\frac{dy}{dx}=6xy$$ with the initial condition that $$y(0) = 4$$.

Solution

This is example 1 from above. Thus, we know that the general solution to this differential equation is $$Ce^{3x^2}$$. Now, we use the initial condition to find $$C$$. The initial condition tells us that when $$x=0$$, our function $$y$$ will equal 4. So,

$$y(0) = 4 \implies Ce^{3(0)^2} = 4 \implies Ce^{0} = 4 \implies C(1) = 4 \implies C=4$$

Therefore, $$y=4e^{3x^2}$$ is the solution to the differential equation with the initial condition that $$y(0) = 4$$.

## First Order Linear Differential Equations (FOLDEs)

Recall that First Order Linear Differential Equations (FOLDEs) are of the form $$\frac{dy}{dx} + P(x)y = Q(x)$$ where $$P(x), Q(x)$$ are functions of $$x$$. Even if the differential equation does not look like this at first glance, it could be rearranged to be in this form. Once you get your differential equation in this form, you can follow these steps to find the general solution:

1. Identify $$P(x), Q(x)$$
2. Calculate a new function $$I(x) = e^{\int P(x)\,dx}$$ which we will call the integrating factor
3. Calculate $$yI = \int Q(x)I\,dx$$
4. Isolate for $$y$$ to get the general solution

## Examples

Example 1

Solve the FOLDE: $$\frac{dy}{dx} + (\frac{2}{x})y = 5x^2$$

Solution

1. Start by identifying $$P(x), Q(x)$$. Here we have $$P(x) = \frac{2}{x}$$ and $$Q(x) = 5x^2$$.

2. Next, calculate the integrating factor:

\begin{align} I(x) &= e^{\int P(x)\,dx} \\ &= e^{\int \frac{2}{x}}\,dx \\ &= e^{2ln|x|} \\ &= e^{ln|x|^2} \\ &= e^{ln(x^2)} \\ &= x^2 \end{align}

Thus, we have $$I(x) = x^2$$. Note that we ignore the $$+C$$ because we only need one integrating factor, not all of them. The absolute values are ignored for the same reason in the derivative of $$\frac{2}{x}$$.

3. Now, plug these values into $$yI(x) = \int Q(x)I(x)\,dx$$

\begin{align} yI(x) &= \int Q(x)I(x)\,dx \\ \implies \qquad yx^2 &= \int 5x^2(x^2)\,dx \\ \implies \qquad yx^2 &= \int 5x^4\,dx \\ \implies \qquad yx^2 &= x^5 + C \end{align}

4. Now, we can use this to solve for the general solution:

\begin{align} yx^2 &= x^5 + C \\ \implies \qquad y &= x^3 + \frac{C}{x^2} \\ \implies \qquad y &= x^3 + Cx^{-2} \end{align}

Example 2

Solve the differential equation: $$x\frac{dy}{dx} - 3y = 3x^3$$

Solution

1. This is not in the correct form for us to apply our techniques. However, we can divide both sides by $$x$$ to get $$\frac{dy}{dx} -\frac{3}{x}y = 3x^2$$. This is now in the correct form where $$P(x) = \frac{-3}{x}$$ and $$Q(x) = 3x^2$$.

2. We can use this to calculate the integrating factor:

\begin{align} I(x) &= e^{\int P(x)\,dx} \\ &= e^{\int \frac{-3}{x}\,dx} \\ &= e^{-3ln(x)} \\ &= e^{lnx^{-3}} \\ &= x^{-3} \end{align}

3. Now, we can substitute this into our formula:
\begin{align} yI(x) = \int Q(x)I(x)\,dx \\ yx^{-3} &= \int 3x^2(x^{-3})\,dx \\ yx^{-3} &= \int \frac{2}{x}\,dx \\ yx^{-3} &= 2ln(x) + C \end{align}

4. Finally, solve for $$y$$:

\begin{align} yx^{-3} &= 2ln(x) + C \\ \frac{y}{x^3} &= ln(x^2) + C \\ y &= x^3(ln(x^2)+ C) \end{align}

Thus, the general solution to the differential equation is $$y = x^3(ln(x^2)+ C)$$