An ordinary differential equation or ODE (as opposed to a partial differential equation) is a type of differential equation that involves a function of only one independent variable. It can simply be defined, for a layman, as any equation that involves any combination of the following:

• An independent variable (${\displaystyle x}$)
• Functions of the independent variable (or dependent variables) (${\displaystyle g(x)}$)
• A primary dependent variable (the function in question) (${\displaystyle y(x)}$)
• And, necessarily, any number of and degrees of derivatives of the primary function (${\displaystyle {\frac {dy}{dx}},{\frac {d^{2}y}{dx^{2}}}}$)

An example differential equation is as follows:

${\displaystyle x^{2}y+3{\frac {d^{2}y}{dx^{2}}}-xy{\frac {d^{2}y}{dx^{2}}}=3}$

## Methods of solving

### First order

First order first degree differential equations in the form

${\displaystyle {\frac {dy}{dx}}=f(x)}$

Can be solved with direct integration.

#### Separable equations

Separable equations are the one of the easiest to solve. For any ODE in the form

${\displaystyle \frac{dy}{dx}=f(x)g(y)}$

the solution is

${\displaystyle \int {\frac {dy}{g(y)}}=\int f(x)dx}$

#### General linear equations

For linear equations in the form

${\displaystyle \frac{dy}{dx} + f(x)y = g(x)}$,

the solution can be found with the formula

${\displaystyle y={\frac {1}{\mu }}\left(\int \mu g(x)dx+C\right),\,\,\mu =e^{\int f(x)dx}}$

#### Bernoulli equations

Bernoulli differential equations are those in the form

${\displaystyle {\frac {dy}{dx}}+f(x)y=g(x)y^{n}}$,

They can be solved by transforming them into linear differential equations by substituting.

#### Exact equations

Exact differential equations are those in the form

${\displaystyle m(x,y)dx+n(x,y)dy=0\,\,{\text{if}}\,\,{\frac {\partial }{\partial y}}m(x,y)={\frac {\partial }{\partial x}}n(x,y)}$

and will have the solution

${\displaystyle \int m(x,y)dx+\int n(x,y)dy=C}$

#### Systems of differential equations

A system of ODEs in the form

${\displaystyle {\begin{bmatrix}x'_{1}\\\vdots \\x'_{n}\end{bmatrix}}={\begin{bmatrix}C_{11}&\cdots &C_{1n}\\\vdots &\ddots &\vdots \\C_{n1}&\cdots &C_{nn}\end{bmatrix}}{\begin{bmatrix}x_{1}\\\vdots \\x_{n}\end{bmatrix}}}$

or, in more compact notation,

${\displaystyle {\vec {x}}'=A{\vec {x}}}$

the general solution will be

${\displaystyle {\vec {x}}=C_{1}{\vec {v}}_{1}e^{\lambda _{1}t}+\cdots +C_{n}{\vec {v}}_{n}e^{\lambda _{n}t}}$

where ${\displaystyle \vec{v}}$ and ${\displaystyle \lambda}$ represent the eigenvectors and eigenvalues of A, respectively. Higher order differential equations can be converted into such a system by making the substitution

${\displaystyle x_{n}=y^{(n)}(t)}$

differentiating, and substituting variables from the original equation for derivatives of y to yield a system of first order ODEs. For example:

${\displaystyle y''-2y'+y=0}$

We can make the substition

${\displaystyle {\begin{bmatrix}x_{1}\\x_{2}\end{bmatrix}}={\begin{bmatrix}y\\y'\end{bmatrix}}}$
${\displaystyle {\begin{bmatrix}x_{1}\\x_{2}\end{bmatrix}}'={\begin{bmatrix}y'\\y''\end{bmatrix}}={\begin{bmatrix}x_{2}\\2x_{2}-x_{1}\end{bmatrix}}}$
${\displaystyle {\vec {x}}'={\begin{bmatrix}0&1\\2&-1\end{bmatrix}}{\vec {x}}}$

### Higher order equations

In general, if f(x) and g(x) are both solutions to a differential equation, C1f(x) + C2g(x) is also a solution.

#### Homogenous equations

${\displaystyle a{\frac {d^{2}y}{dx^{2}}}+b{\frac {dy}{dx}}+cy=0}$

Differential equations in this form can be solved by first finding the roots of the auxiliary or characteristic equation, which is equal to

${\displaystyle ar^{2}+br+c=0}$

The roots may be real or complex. If the roots are ${\displaystyle r_{1}, r_{2}}$ then the general solution will be:

${\displaystyle y=C_{1}e^{r_{1}x}+C_{2}e^{r_{2}x}}$

If the characteristic equation has only one solution, the general solution of the ODE will be

${\displaystyle y=C_{1}e^{rx}+C_{2}xe^{rx}}$

If the roots are complex and equal to ${\displaystyle a\pm bi}$, by Euler's formula the solution simplifies to

${\displaystyle y=e^{ax}(C_{1}\cos(bx)+C_{2}\sin(bx))}$

The constant of integration is not restricted to real numbers in this case.

#### Method of undetermined coefficients

This method is used to find a particular solution for non-homogeneous equations by using a similar function as a potential particular solution YP and adjusting the coefficients. It is especially useful when the forcing term is a polynomial, trigonometric function, or exponential function, however if there is information known about the particular integral required different guesses can be tried.

For example:

${\displaystyle y''+3y'-4y=3x^{2}}$
${\displaystyle Y_{p}=Ax^{2}+Bx+C,\;\;Y'_{p}=2Ax+B,\;\;Y''_{p}=2A}$
${\displaystyle 2A+3(2Ax+B)-4(Ax^{2}+Bx+C)=3x^{2}}$

This equality now creates a linear system of equations.

${\displaystyle -4A=3}$
${\displaystyle 6A-4B=0}$
${\displaystyle 2A+3B-4C=0}$
${\displaystyle A=-{\frac {3}{4}},\;\;B=-{\frac {9}{8}},\;\;C=-{\frac {39}{32}}}$
${\displaystyle Y_{p}=-{\frac {3}{4}}x^{2}-{\frac {9}{8}}x-{\frac {39}{32}}}$

This particular solution, combined with the general solution of the associated homogeneous equation, gives a final general solution of

${\displaystyle y=C_{1}e^{-4x}+C_{2}e^{x}-{\frac {3}{4}}x^{2}-{\frac {9}{8}}x-{\frac {39}{32}}}$

## Real world examples

### Murder case

Detectives find a murder victim in room with the thermostat set to 20 °C at 4:30 AM. The detectives take a measurement as soon as they arrive and find the body to be 27 °C. An hour later the body is at 25 °C. What time was the victim killed?

This problem can be solved by using Newton's Law of Cooling, which states

${\displaystyle {\frac {dT}{dt}}=-k(T-a)}$

${\displaystyle T}$ is temperature, the dependent variable, ${\displaystyle t}$ is time, the independent variable, ${\displaystyle a}$ is the ambient temperature and ${\displaystyle k}$ is a constant. Since the variables can be separated, we can find the solution using that method.

${\displaystyle {\frac {dT}{dt}}=-k(T-a)}$
${\displaystyle {\frac {dT}{(T-a)}}=-kdt}$
${\displaystyle \int {\frac {dT}{(T-a)}}=\int -kdt}$
${\displaystyle \ln(T-a)=-kt+C}$
${\displaystyle T=Ce^{-kt}+a}$
${\displaystyle T=Ce^{-kt}+20}$

Firstly, we must find ${\displaystyle C}$. We can do this with the initial value ${\displaystyle T(0)=36.8}$ (human body temperature).

${\displaystyle 36.8=Ce^{0}+20}$
${\displaystyle 36.8=C+20}$
${\displaystyle C=16.8}$

We can now solve for ${\displaystyle x}$ and ${\displaystyle k}$. We will assume that 4:30 is ${\displaystyle x}$ hours after death.

${\displaystyle 27=16.8e^{-kx}+20,25=16.8e^{-k(x+1)}+20}$
${\displaystyle k=-{\frac {\ln({\frac {7}{16.8}})}{x}}={\frac {0.875}{x}},k=-{\frac {\ln({\frac {5}{16.8}})}{x+1}}={\frac {1.212}{x+1}}}$
${\displaystyle {\frac {0.875}{x}}={\frac {1.212}{x+1}}}$
${\displaystyle x=2.597}$

The murder took place 2.597 hours ago, or at 1:56 AM. We can also find ${\displaystyle k}$ and find our final solution, although this is unnecessary as far as the detectives are concerned since we already know the time of death.

${\displaystyle 27=16.8e^{-2.597k}+20}$
${\displaystyle k={\frac {0.875}{x}}={\frac {0.875}{2.597}}=0.337}$
${\displaystyle T=16.8e^{-0.337t}+20}$

Polunium-208 has a half life of 2.898 years. If the original sample was 10 grams, how much will remain after 1 year?

We can set this up as a differential equation, with ${\displaystyle A}$ as the amount, ${\displaystyle t}$ as time, and ${\displaystyle k}$ as a constant.

${\displaystyle {\frac {dA}{dt}}=kA}$

This is a separable differential equation, and can be solved to give

${\displaystyle \ln(A)=kt+C}$
${\displaystyle A=Ce^{kt}}$

Since we have the initial value ${\displaystyle A(0)=10}$, we can find C.

${\displaystyle 10=Ce^{k0}=Ce^{0}=C}$
${\displaystyle A=10e^{kt}}$

${\displaystyle k}$ can be found since we know that after 2.898 years there will be 5 grams.

${\displaystyle 5=10e^{2.898k}}$
${\displaystyle k={\frac {\ln({\frac {1}{2}})}{2.898}}=-0.239}$

We know have a complete formula, which we can use to calculate out answer.

${\displaystyle A=10e^{-0.239t}}$
${\displaystyle A(1)=10e^{-0.239}=10(0.787)=7.87}$

Our amount of Polunium-208 after 1 year is 7.87 grams.

### Simple harmonic motion

A system which obeys Hooke's law, or

${\displaystyle F = -kx}$

can be rewritten as a second-order differential equation.

Using Newton's 2nd Law,

${\displaystyle \sum F=ma}$
${\displaystyle \implies F=-kx=m{\frac {d^{2}x}{dt^{2}}}}$
${\displaystyle \frac{d^2 x}{dt^2} + \frac{k}{m} x = 0}$

This equation will have the characteristic equation

${\displaystyle r^2 + \frac{k}{m} = 0}$
${\displaystyle r = \pm \sqrt{-\tfrac{k}{m}} = \pm \sqrt{\tfrac{k}{m}} i = \pm \omega i}$

The solution to the differential equation is

${\displaystyle x(t) = C_1 e^{r_1 t} + C_2 e^{r_2 t} = C_1 e^{\omega i t} + C_2 e^{-\omega i t}}$

By using Euler's formula this can be written in the form

${\displaystyle x(t) = C_1 (\cos (\omega t) + i \sin(\omega t)) + C_2 (\cos (\omega t) - i \sin(\omega t))}$
${\displaystyle x(t) = (C_1 + C_2) \cos (\omega t) + (C_1 - C_2) \sin (\omega t)}$
${\displaystyle x(t) = C_3 \cos (\omega t) + C_4 \sin (\omega t)}$

which, by trigonometric identities, can be written as

${\displaystyle x(t) = A \cos (\omega t - \varphi)}$

where ${\displaystyle A = \sqrt{C_3^{ \ 2} + C_4^{ \ 2}}}$ and ${\displaystyle \tan \varphi = \tfrac{C_4}{C_3}}$. Systems which follow this equation are said to exhibit simple harmonic motion.