Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

1. Solution by direct integration

When equations are of this form, we can directly integrate:

dydx=y=f(x)dy=f(x)dxy(x)=f(x)dx+C\begin{align} \frac{dy}{dx} &= y^{\prime} = f(x) \\ \int dy &= \int f(x) dx \\ y(x) &= \int f(x) dx + C \end{align}

For example:

dydx=x2y(x)=13x3+C\begin{align} \frac{dy}{dx} &= x^2 \\ y(x) &= \frac{1}{3} x^3 + C \end{align}

While these problems look simple, there may not be an obvious closed-form solution to all:

dydx=ex2y(x)=ex2dx+C\begin{align} \frac{dy}{dx} &= e^{-x^2} \\ y(x) &= \int e^{-x^2} dx + C \end{align}

(You may recognize this as leading to the error function, erf\text{erf}: 12πerf(x)+C\frac{1}{2} \sqrt{\pi} \text{erf}(x) + C, so the exact solution to the integral over the range [0,1][0,1] is 0.7468.)

2. Solution by separation of variables

If the given derivative is a separate function of xx and yy, then we can solve via separation of variables:

dydx=f(x)g(y)=h(x)j(y)1g(y)dy=f(x)dx\begin{align} \frac{dy}{dx} &= f(x) g(y) = \frac{h(x)}{j(y)} \\ \int \frac{1}{g(y)} dy &= \int f(x) dx \end{align}

For example, consider this problem:

y=dydx=1+y2y^{\prime} = \frac{dy}{dx} = 1 + y^2 \\

We can separate this into a problem that looks like f(y)dy=g(x)dxf(y) dy = g(x) dx, where dy=11+y2dy = \frac{1}{1+y^2} and g(x)=1g(x) = 1.

dy1+y2=dxarctany=x+cy(x)=tan(x+c)\begin{align} \int \frac{dy}{1 + y^2} &= \int dx \\ \arctan y &= x + c \\ y(x) &= \tan(x+c) \end{align}

Unfortunately, not every separable ODE can be integrated:

dydx=ex/2+5y2+cosy(y2+cosy)dy=(ex/2+5)dx\begin{align} \frac{dy}{dx} &= \frac{e^x / 2 + 5}{y^2 + \cos y} \\ (y^2 + \cos y) dy &= (e^x / 2 + 5) dx \end{align}

3. General solution to linear 1st-order ODEs

Given a general linear 1st-order ODE of the form

dydx+p(x)y=q(x)\frac{dy}{dx} + p(x) y = q(x)

we can solve by integration factor:

y(x)=ep(x)dx[ep(x)dxq(x)dx+C]y(x) = e^{-\int p(x) dx} \left[ \int e^{\int p(x) dx} q(x) dx + C \right]

For example, in this equation

y+xy5ex=0y^{\prime} + xy - 5 e^x = 0

after rearranging to the standard form

y+xy=5exy^{\prime} + xy = 5 e^x

we see that p(x)=xp(x) = x and q(x)=5exq(x) = 5e^x.

4. Solution to nonlinear 1st-order ODEs

Given a general nonlinear 1st-order ODE

dydx+p(x)y=q(x)ya\frac{dy}{dx} + p(x) y = q(x) y^a

where a1a \neq 1 and aa is a constant. This is known as the Bernoulli equation.

We can solve by transforming to a linear equation, by changing the dependent variable from yy to zz:

letz=y1adzdx=(1a)yadydx\begin{align} \text{let} \quad z &= y^{1-a} \\ \frac{dz}{dx} &= (1-a) y^{-a} \frac{dy}{dx} \end{align}

Multiply the original equation by (1a)ya(1-a) y^{-a}:

(1a)yadydx+(1a)yap(x)y=(1a)yaq(x)yadzdx+p(x)(1a)z=q(x)(1a)  ,\begin{align} (1-a) y^{-a} \frac{dy}{dx} + (1-a) y^{-a} p(x) y &= (1-a) y^{-a} q(x) y^a \\ \frac{dz}{dx} + p(x) (1-a) z &= q(x) (1-a) \;, \end{align}

which is now a linear first-order ODE, that looks like

dzdx+p(x)z=q(x)\frac{dz}{dx} + p(x)^{\prime} z = q(x)^{\prime}

where p(x)=(1a)p(x)p(x)^{\prime} = (1-a) p(x) and q(x)=(1a)q(x)q(x)^{\prime} = (1-a)q(x).

We can solve this using the integrating-factor approach discussed above. Then, once we have z(x)z(x), we can find y(x)y(x):

z=y1ay=z11a\begin{align} z &= y^{1-a} \\ y &= z^{\frac{1}{1-a}} \end{align}