### Ordinary Differential Equations

A differential equation is an equation with $\frac{d^n}{dx^n}$ terms. Let's start with a simple equation with two variables $x$ and $y$.

$y = ae^x + be^{3x}$

If we differentiate this in $x$, a first order differential equation comes as

$\frac{dy}{dx} = ae^x + 3be^{3x}$

If we differentiate it once more in terms of $x$, a second order differential equation is produced as

$\frac{d^2y}{dx^2} = ae^x + 9be^{3x}$

By solving there three equations, we can get an equation without those constant terms $a$ and $b$ and that is called an ordinary differential equation.

### Methods of solving an Ordinary Differential Equation

There are several methods we can use to solve these type of equations. They are
• Variable Seperable method
• Homogeneous Equation method
• First Order Linear Differential Equation method
• Bernoulli Equation method

#### Variable Seperable method

If an ordinary differential equation possesses the following layout, we can use this method to solve it. $$\frac{dy}{dx} = f(x)h(y)$$ Then by using fraction theories, we can simple it down to, $$\int{\frac{1}{h(y)}dy} = \int{f(x)dx}$$

#### Homogeneous Equation method

If an ordinary differential equation possess terms of the same degree in both numerator and denominator, we can use this method to solve it. Let's try to get this explained by an example. $$\frac{dy}{dx} = \frac{x^2 + xy}{y^2 + xy}$$ As it is observed, every term in both numerator and denominator have two degrees (despite to the fact that they are different variables), so we can use a substitution to make it much simpler.

take $y = vx$ and that implies by differentiating $\frac{dy}{dx} = v + x\frac{dv}{dx}$. So the equation simplifies into; $$v + x\frac{dv}{dx} = \frac{x^2 + xvx}{(vx)^2 + xvx}$$ $$x\frac{dv}{dx} = \frac{2v}{v-1}$$ $$\int{\frac{v-1}{2v}dv} = \int{\frac{1}{x}dx}$$

#### First Order Linear Differential Equation method

Let's take a first order linear differential equation like the one below, $$\frac{dy}{dx} + P(x)y = Q(x)$$ Here, $P(x)$ and $Q(x)$ can be either a constant or a function of $x$. Now multiply both sides by $R(x)$ which is a function of $x$. So you will get, $$R(x)\frac{dy}{dx} + R(x)P(x)y = R(x)Q(x)$$ $$R(x)\frac{dy}{dx} + y\frac{dR(x)}{dx} - y\frac{dR(x)}{dx} + R(x)P(x)y = R(x)Q(x)$$ $$\frac{d[yR(x)]}{dx} + y\left(R(x)P(x) - \frac{dR(x)}{dx}\right) = R(x)Q(x)$$ Now let's try to find a suitable expression for $R(x)$ such that $$R(x)P(x) - \frac{dR(x)}{dx} = 0$$ $$\int P(x) dx = \int{\frac{1}{R} dR}$$ So comes a factor which is called the Integrating Factor $$IF = R(x) = e^{\int{P(x)dx}}$$ Let's see how it looks in an example.

We are given, $$\frac{dy}{dx} - \frac{y}{x} = e^x$$ By comparing with the defined equation, we can see that $P(x) = \frac{-1}{x}$. So the integrating factor is $e^{\int P(x) dx}$ which is simplified into $\frac{1}{x}$. By multiplying the equation with IF we get, $$\frac{1}{x}\frac{dy}{dx} - \frac{y}{x^2} = \frac{e^x}{x}$$ $$\frac{d\left(\frac{y}{x}\right)}{dx} = \frac{e^x}{x}$$ By taking integral and simplifying, we get $$y = x\left[\int{\frac{e^x}{x}dx + c}\right]$$ This can be re-written as; $$y = x\left[\int_{1}^{x}{\frac{e^t}{t}dt + c}\right]$$

#### Bernoulli Equation method

If an equation has this layout, we can solve it using Bernoulli Equation method $$\frac{dy}{dx} + P(x)y = Q(x)y^n$$ Let's try to simplify it as follows $$\frac{1}{y^n}\frac{dy}{dx} + P(x)y^{(1-n)} = Q(x)$$ Now if we take $z = y^{(1-n)}$, we get $\frac{dz}{dx} = (1-n)y^{-n}\frac{dy}{dx}$ and the equation simplifies into, $$\frac{dz}{dx} + (1-n)P(x)z = Q(x)(1-n)$$ Then we can simplify it using First Order Linear Differential Equation method.