# Chapter 4 First and second order ODEs

Not all ODEs are analytically solvable. In this section we discuss some types of first and second order ODEs that are analytically solvable and see some examples.

## 4.1 First order ODEs

A first order ODE has only the first derivative represented. The general implicit form for a first order ODE for the function $$x(t)$$ is: $G(t, x, \frac{dx}{dt}) = 0,$ and its explicit form is: $\frac{dx}{dt} = F(x, t).$

In the following we discuss some classes of first order ODEs and describe methods of obtaining a solution for them. These inculde separable and linear first order ODEs. The other types of First Order ODEs that can be solved are based on transformations or change of variables. We see two examples of this in the following. Another important class of first order ODEs that can be solved are Exact ODEs that will be discussed in part III of the course after introducing partial and total differentiation.

### 4.1.1 Separable First Order ODEs

A separable first order ODE can be written in the following form: $\frac{dx}{dt} = F_1(x) F_2(t).$ Solution Rearranging and integrating both sides we get: $\int \frac{dx}{F_1(x)} = \int F_2(t) dt + c_1.$

### 4.1.2 Linear First Order ODEs

First order linear ODEs have the following general form: $\frac{dy}{dx} + p(x)y = q(x).$ Solution This is solved by finding an integrating factor (IF). We look for $$I(x)$$ such that: $I(x)\left[\frac{dy}{dx} + p(x)y\right] = \frac{d[I(x)y]}{dx},$ Then, we have \begin{align*} \frac{d[I(x)y]}{dx} & = I(x)q(x),\\ \int d[I(x) y] & = \int q(x)I(x) \,dx + c_1,\\ y(x) & = \frac{1}{I(x)} \left[\int q(x)I(x) \, dx + c_1 \right]. \end{align*}

Integrating factors must fulfil: \begin{align*} \frac{d(Iy)}{dx} & = I \frac{dy}{dx} + Ipy, \\ I \frac{dy}{dx} + y \frac{dI}{dx} & = I\frac{dy}{dx} + Ipy,\\ \int \frac{dI}{I} & = \int p(x) \,dx + c'.\\ \end{align*} So we have: $I(x) = A e^{\int p(x)\, dx},$ where $$A$$ is a new arbitrary constant (of integration).

So, we have the following for the general solution: $y(x) = e^{-\int p(x)\, dx} \left[\int e^{\int p(x)\, dx} q(x) \, dx + c \right],$ where $$c = c_1/A$$ is a new arbitrary constant of integration.

### 4.1.3 Dimensionally Homogeneous

The dimensionally homogeneous have the following general form: $\frac{dy}{dx} = F\left( \frac{y}{x}\right).$ Solution Let $$u = y/x$$ we obtain: $\frac{dy}{dx} = u + x \frac{du}{dx}$ The ODE in terms of $$u(x)$$, which is separabale is $u + x \frac{du}{dx} = F(u),$ Finding general solution $$u_{GS}(x)$$ for this ODE then we find the general solution for the original ODE as $$y_{GS}(x) = u_{GS}(x) x$$.

### 4.1.4 Bernoulli ODEs

There are other examples of transformations can turn specific ODEs into separable or linear. Some such as Bernoulli are classic: $\frac{dy}{dx} + p(x) y = q(x) y^n,$ where $$n \in \mathbb{R}$$.

Solution We use the change of variable $$u = y^{1-n}$$. We obtain: $\frac{du}{dx} = (1-n) y^{-n} \frac{dy}{dx}.$ Writing the original ODE in terms of $$u$$ we have: $\frac{du}{dx} + (1-n) p(x) u = (1-n) q(x),$ which is a linear ODE for $$u(x)$$, so we obtain $$u_{GS}(x)$$ and then we have $y_{GS} = u_{GS}^{\frac{1}{1-n}}.$

## 4.2 Second Order ODEs

The general implicit form is: $G(x, y, \frac{dy}{dx}, \frac{d^2y}{dx^2}) = 0,$ and the general explicit form is: $\frac{d^2y}{dx^2} = F(x, y, \frac{dy}{dx}).$

The second order ODEs are common in Mechanics as Newton’s second law is such ODE with independent variable as time $$t$$. They are difficult to solve for general $$F$$ but there are some special cases that can be solved as described in the following. Also, the linear case is discussed in the next chapter in detail.

### 4.2.1$$F$$ only depends on $$x$$

$\frac{d^2y}{dx^2} = F(x)$ Solution Let $$u = \frac{dy}{dx}$$ then we have $$\frac{du}{dx} = F(x)$$. A first integration gives us: $u = \int F(x) dx + c_1$ A second integration then gives us $$y_{GS}$$: $y_{GS} = \int \left[\int F(x) dx\right] dx + c_1x + c_2.$

### 4.2.2$$F$$ only depends on $$x$$ and $$\frac{dy}{dx}$$

$\frac{d^2y}{dx^2} = F(x, \frac{dy}{dx})$ Solution Let $$u = \frac{dy}{dx}$$ then we have $$\frac{du}{dx} = F(x, u)$$, which is a first order ODE. If we could obtain the general solution $$u_{GS}(x; c_1)$$ then we have: $y_{GS}(x) = \int u_{GS}(x; c_1) \, dx + c_2.$

### 4.2.3$$F$$ only depends on $$y$$

$\frac{d^2y}{dx^2} = F(y)$

Solution We let $$u = \frac{dy}{dx}$$ then $$\frac{du}{dx} = F(y)$$. Then we have: $\frac{du}{dx} = \frac{du}{dy} \frac{dy}{dx} = u \frac{du}{dy} = \frac{d}{dy}\left( \frac{1}{2}u^2 \right) = F(y),$ which is a first order separable ODE for $$u(y)$$. We have: $\frac{1}{2}u^2 = \int F(y)dy + c_1 = G(y) + c_1.$ So we have: $\frac{dy}{dx} = u = \pm \sqrt{2 G(y) + 2c_1},$ which is a first order separable ODE for $$y(x)$$ and can be integrated to obtain $$y_{GS}(x; c_1, c_2)$$ as seen in the following example.

Example 4.1 (Mechanics Harmonic Oscillator) Hooke’s law states if $$x(t)$$ is displacement relative to an ideal spring relaxed position, the spring force is: $$F = -kx$$ Using second Newton Law we have: $$ma = F \quad \Longrightarrow \quad m\frac{d^2x}{dt^2} = - kx$$

Let velocity to be $$u = \frac{dx}{dt}$$, then we have: $a = \frac{du}{dt} = \frac{d}{dx}\left[\frac{1}{2}u^2\right] = -\frac{kx}{m}.$ Integrating both sides we obtain: $\frac{u^2}{2} = -\frac{k}{2m} x^2 + c_1.$ This equation gives us a constant of motion $$(E = c_1 m)$$, which is known as total energy, the sum of kinetic energy ($$1/2mu^2$$) and potential energy ($$1/2 k x^2$$).

$$u = \frac{dx}{dt} = \pm \sqrt{\frac{2E - kx^2}{m}} \quad \Longrightarrow \quad \displaystyle\int \frac{dx}{\pm \sqrt{\frac{2E - kx^2}{m}} } = \displaystyle\int dt$$

Sticking with the postive sign on the LHS we have: $\frac{1}{\sqrt{2E/m}}\displaystyle\int \frac{dx}{\sqrt{1 - \frac{k}{2E}x^2} } = \sqrt{\frac{m}{k}}\sin^{-1}\left(\sqrt{\frac{k}{2E}}x\right) = t + c_2$ Rearranging the solution we obtain: $x_{GS} = A \sin(\omega t + \phi),$ where, $$\omega = \sqrt{k/m}$$ is the frequency of oscillations and $$A = \sqrt{2E/k}$$ and $$\phi = \sqrt{k/m} c_2$$ are new constants of integration. We note that, if we had chosen to use the minus sign above, we would have obtained the same family of solutions but the constants of integrations would be differently defined.

### 4.2.4$$F$$ only depends on $$y$$ and $$\frac{dy}{dx}$$

$\frac{d^2y}{dx^2} = F(y, \frac{dy}{dx})$

let $$u = \frac{dy}{dx} \quad \Longrightarrow \quad \frac{du}{dx} = F(y, u).$$ So we have $\frac{du}{dx} = \frac{du}{dy} \frac{dy}{dx} = u \frac{du}{dy} = \frac{d}{dy}\left( \frac{1}{2}u^2 \right).$ Therefore we have the following first order ODE for $$u(y)$$ to solve $\frac{d}{dy}\left( \frac{1}{2}u^2 \right) = F(y, u).$ Given $$u_{GS}(y; c_1)$$ being a general solution for the above ODE, we have the following first order ODE for $$y(x)$$: $\frac{dy}{dx} = u_{GS}(y; c_1).$