# Ordinary Differential Equations/Substitution 1

    First-Order Differential Equations
As we saw in a previous example, sometimes even though an equation isn't separable in its original form, it can be factored into a form where it is. Another way you can turn non-separable equations into separable ones is to use substitution methods.

## General substitution procedure

All substitution methods use the same general procedure:
* Take a term of the equation and replace it with a variable v. The key is that the new variable must cover all instances of the variable y. Otherwise substitution would not help.
* Solve for ${\frac {dy}{dx}}$ in terms of $v$ and ${\frac {dv}{dx}}$. To do this, take the equation $v=f(x,y)$ where $f$ is the term you replaced and take its derivative.
* Plug in ${\frac {dv}{dx}}$ and solve for $v$.
* Plug $v$ into the original term replaced, and solve for $y$.

## Constant coefficient substitution

Lets say we have an equation with a term ay + bx + c, such as
    ${\frac {dy}{dx}}=G(ay+bx+c).$
where G is a function. This is non-separable. But we can sometimes solve these equations by turning the term into a function v, defining v(x,y) and finding v'(x,y,y').
    $v(x,y)=ay+bx+c\,$
The trick with the derivation of v is that y is also a function of x. The derivative of v thus becomes
    ${\frac {dv}{dx}}=a{\frac {dy}{dx}}+b$
In maxima this looks like so:
    (%i1) v:a*y(x)+b*x+c;
and
    (%i2) diff(v,x);
yielding
    (%o1) a*(dy/dx)+b
Next, we rearrange terms and solve for y'(x,v,v'):
    ${\frac {dy}{dx}}={\frac {{\frac {dv}{dx}}-b}{a}}$
Now plug v back into the original equation, ${\frac {dy}{dx}}=G(ay+bx+c)$, and get it into the form ${\frac {dv}{dx}}=f(v)$
    ${\frac {{\frac {dv}{dx}}-b}{a}}=G(v)$
    ${\frac {dv}{dx}}=aG(v)+b$
Solve for v, that is integrate on both sides:
    ${\frac {dv}{dx}}=aG(v)+b$
    ${\frac {dv}{aG(v)+b}}=dx$
    $\int {\frac {dv}{aG(v)+b}}=\int dx$
    $\int {\frac {dv}{aG(v)+b}}=x+D$
Once you have v(x), plug back into the definition of v(x) to get y(x).
    $y(x)={\frac {v(x)-c-bx}{a}}$
It is highly suggested that one should not memorize this equation, and instead remember the method of solving the problem. The final equation is rather obscure and easy to forget, but if one knows the method, he/she can always solve it. It will also help if one uses other substitution methods.

### Example 1

    ${\frac {dy}{dx}}=(x+y+3)^{2}$
Lets replace the quantity being raised to a power with v.
    $v=x+y+3\,$
Now lets find v'.
    ${\frac {dv}{dx}}={\frac {dy}{dx}}+1$
Solve for y'
    ${\frac {dy}{dx}}={\frac {dv}{dx}}-1$
Plug in for y and y':
    ${\frac {dv}{dx}}-1=v^{2}$
    ${\frac {dv}{dx}}=v^{2}+1$
Now we solve for v, using the methods we learned in Separable Variables:
    ${\frac {dv}{v^{2}+1}}=dx$
    $\int {\frac {dv}{v^{2}+1}}=\int dx$
    $\tan ^{-1}(v)=x+C\,$
    $v=\tan(x+C)\,$
Now that we have v(x), plug back in and find y(x).
    $y+x+3=\tan(x+C)\,$
    $y=\tan(x+C)-x-3\,$

## Other methods

These are not the only possible substitution methods, just some of the more common ones. Substitution methods are a general way to simplify complex differential equations. If you ever come up with a differential equation you can't solve, you can sometimes crack it by finding a substitution and plugging in. Just look for something that simplifies the equation. Remember that between v and v' you must eliminate the y in the equation.

### Example 2

    $2y{\frac {dy}{dx}}=y^{2}+x-1$
This equation isn't separable, and none of the methods we previously used will quite work. Let's use a custom substitution of v = y$^2$ + x − 1. Solve for v':
    ${\frac {dv}{dx}}=2y{\frac {dy}{dx}}+1$
    $2y{\frac {dy}{dx}}={\frac {dv}{dx}}-1$
Plug into the original equation
    ${\frac {dv}{dx}}-1=v$
Solve for v
    ${\frac {dv}{v+1}}=dx$
    $\int {\frac {dv}{v+1}}=\int dx$
    $\ln(v+1)=x+C\,$
    $v=Ce^{x}-1\,$
Now plug in and get y
    $Ce^{x}-1=y^{2}+x-1\,$
    $y^{2}=Ce^{x}-x\,$
Pretty easy after using that substitution. Keep this method in mind, you will use this for more complex equations.