A tutorial on how to solve first order differential equations. Examples with detailed solutions are included.

The general form of the first order linear differential equation is as follows

where P(x) and Q(x) are functions of x.

If we multiply all terms in the differential equation given above by an unknown function u(x), the equation becomes

The left hand side in the above equation has a term u dy / dx, we might think of writing the whole left hand side of the equation as d (u y ) / dx. Using the product rule of derivatives we obtain

d (u y ) / dx = y du / dx + u dy / dx

For y du / dx + u dy / dx and u(x) dy / dx + u(x) P(x) y to be equal, we need to have

du / dx = u(x) P(x)

Which may be written as

(1/u) du / dx = P(x)

Integrate both sides to obtain

ln(u) = ò P(x) dx

Solve the above for u to obtain

u(x) = e

u(x) is called the integrating factor. A solution for the unknown function u has been found. This will help in solving the differential equations.

d(uy) / dx = u(x) Q(x)

Integrate both sides to obtain

u(x) y = ò u(x) Q(x) dx

Finally solve for y to obtain

y = ( 1 / u(x) ) ò u(x) Q(x) dx

Example 1: Solve the differential equation

__Solution to Example 1__

Comparing the given differential equation with the general first order differential equation, we have

P(x) = -2 x and Q(x) = x

Let us now find the integrating factor u(x)

u(x) = e^{ò P(x) dx}

= e^{ò -2 x dx}

= e^{ - x2}

We now substitute u(x)= e^{ - x2} and Q(x) = x in the equation u(x) y = ò
u(x) Q(x) dx to obtain

e^{ - x2} y = ò x e^{ - x2}dx

Integrate the right hand term to obtain

e^{ - x2} y = -(1/2) e^{-x2} + C , C is a constant of integration.

Solve the above for y to obtain

y = C e^{x2} - 1/2

As a practice, find dy / dx and substitute y and dy / dx in the given equation to check that the solution found is correct.

Example 2: Solve the differential equation

__Solution to Example 2__

We first find P(x) and Q(x)

P(x) = 1 / x and Q(x) = - 2

The integrating factor u(x) is given by

u(x) = e^{ò P(x) dx}

= e^{ò (1 / x) dx}

= e^{ln |x|} = | x | = x since x > 0.

We now substitute u(x)= x and Q(x) = - 2 in the equation u(x) y = ò
u(x) Q(x) dx to obtain

x y = ò -2 x dx

Integrate the right hand term to obtain

x y = -x^{2} + C , C is a constant of integration.

Solve the above for y to obtain

y = C / x - x

As an exercise find dy / dx and substitute y and dy / dx in the given equation to check that the solution found is correct.

Example 3: Solve the differential equation

__Solution to Example 3__

We first divide all terms of the equation by x to obtain

dy / dx + y / x = - x^{2}

We now find P(x) and Q(x)

P(x) = 1 / x and Q(x) = - x^{2}

The integrating factor u(x) is given by

u(x) = e^{ò P(x) dx}

= e^{ò (1 / x) dx}

= e^{ln |x|} = | x | = x since x > 0.

We now substitute u(x)= x and Q(x) = - x^{2}
in the equation u(x) y = ò
u(x) Q(x) dx to obtain

x y = ò - x^{3}
dx

Integration of the right hand term yields

x y = -x^{4} / 4 + C , C is a constant of integration.

Solve the above for y to obtain

y = C / x - x^{3} / 4

As an exercise find dy / dx and substitute y and dy / dx in the given equation to check that the solution found is correct.

NOTE: If you can "see" that the right hand side of the given equation

x dy / dx + y = - x^{3}

can be written as d(x y) / dx, the solution can be found easily as follows

d(x y) / dx = - x^{3}

Integrate both sides to obtain

x y = - x^{4} / 4 + C.

Then solve for y to obtain

y = - x^{3} / 4 + C / x

1. dy / dx + y = 2x + 5

2. dy / dx + y = x

1. y = 2x + 3 + C e

2. y = x

More references on
Differential Equations

Differential Equations - Runge Kutta Method