Skip to main content

First-Order ODEs

A first-order ordinary differential equation relates an unknown function to its first derivative. In engineering models the derivative is usually a rate: current changing in a circuit, temperature relaxing toward the surroundings, concentration changing in a mixing tank, or velocity responding to drag. The mathematical work is only one part of the task. A useful solution also records the modeling assumptions, the interval where the solution is valid, the initial condition, and the physical meaning of constants.

This page sits between qualitative ideas such as slope fields and later linear-system methods. The main theme is recognition: identify whether the equation is separable, linear, exact, Bernoulli, homogeneous in y/xy/x, or best handled numerically. Many errors in first-order ODEs come from forcing an equation into a favorite method instead of checking its actual structure.

Definitions

A first-order ODE can be written implicitly as

F(x,y,y)=0F(x,y,y')=0

or explicitly as

y=f(x,y).y'=f(x,y).

An initial value problem adds one condition,

y(x0)=y0,y(x_0)=y_0,

which selects one curve from a family of solution curves. A solution on an interval II is a differentiable function y=h(x)y=h(x) such that h(x)=f(x,h(x))h'(x)=f(x,h(x)) for all xIx\in I.

A separable equation has the form

dydx=g(x)h(y).\frac{dy}{dx}=g(x)h(y).

Where h(y)0h(y)\ne 0, separate and integrate:

1h(y)dy=g(x)dx,1h(y)dy=g(x)dx+C.\begin{aligned} \frac{1}{h(y)}\,dy &= g(x)\,dx,\\ \int \frac{1}{h(y)}\,dy &= \int g(x)\,dx+C. \end{aligned}

A linear first-order equation has standard form

y+p(x)y=r(x).y'+p(x)y=r(x).

The integrating factor

μ(x)=ep(x)dx\mu(x)=e^{\int p(x)\,dx}

makes the left side a product derivative:

μy+μpy=μr,(μy)=μr.\begin{aligned} \mu y'+\mu p y &= \mu r,\\ (\mu y)' &= \mu r. \end{aligned}

An exact equation has differential form

M(x,y)dx+N(x,y)dy=0M(x,y)\,dx+N(x,y)\,dy=0

and is exact on a simply connected region when My=NxM_y=N_x. Then there is a potential function u(x,y)u(x,y) with ux=Mu_x=M and uy=Nu_y=N, and the implicit solution is u(x,y)=Cu(x,y)=C.

A Bernoulli equation is

y+p(x)y=g(x)ya,a0,1.y'+p(x)y=g(x)y^a,\qquad a\ne 0,1.

The substitution v=y1av=y^{1-a} converts it into a linear equation for vv.

Key results

The existence and uniqueness theorem gives the basic local guarantee. If f(x,y)f(x,y) and fy(x,y)f_y(x,y) are continuous in a rectangle around (x0,y0)(x_0,y_0), then the initial value problem y=f(x,y)y'=f(x,y), y(x0)=y0y(x_0)=y_0, has exactly one solution near x0x_0. The theorem is local: it does not promise that the solution exists forever, and it does not say that the formula will be elementary.

For separable equations, constant solutions can be lost by division. If y=y(1y)y'=y(1-y), separating by dividing through by y(1y)y(1-y) assumes y0y\ne 0 and y1y\ne 1, so the equilibrium solutions y=0y=0 and y=1y=1 must be added separately. These equilibria often control the long-term behavior.

For linear equations, the integrating factor formula is

y(x)=1μ(x)(μ(x)r(x)dx+C).y(x)=\frac{1}{\mu(x)} \left( \int \mu(x)r(x)\,dx+C \right).

For exact equations, a reliable construction is

u(x,y)=M(x,y)dx+ϕ(y),uy(x,y)=N(x,y).\begin{aligned} u(x,y)&=\int M(x,y)\,dx+\phi(y),\\ u_y(x,y)&=N(x,y). \end{aligned}

The second line determines ϕ(y)\phi'(y). If the leftover expression still contains xx, the equation was not exact or a computation error occurred.

For autonomous equations y=f(y)y'=f(y), the phase line gives stability without solving. An equilibrium yy_* satisfies f(y)=0f(y_*)=0. If f(y)>0f(y)\gt 0 below yy_* and f(y)<0f(y)\lt 0 above it, nearby solutions move toward yy_* and the equilibrium is stable. If arrows point away, it is unstable.

Most engineering uses of first-order equations start from a balance law rather than from a ready-made formula. In a mixing problem, the dependent variable is usually amount, not concentration, because the balance is most naturally written as amount per time. In a cooling problem, the dependent variable is temperature, and the proportional term must use the difference from ambient temperature, not the absolute temperature. In a circuit model, Kirchhoff's law determines whether the state variable should be charge, current, or capacitor voltage. Choosing the state variable well often makes the equation linear.

The interval of validity is part of the answer. A formula may contain a logarithm, a denominator, or a square root that restricts xx, and the initial point must lie in the chosen interval. For example, the solution of y=y2y'=y^2, y(0)=1y(0)=1, is y=1/(1x)y=1/(1-x), which blows up at x=1x=1. The existence theorem gives local existence near 00, but it does not contradict finite-time blow-up.

Some equations become linear only after a change of variables. Bernoulli equations are the standard example, but homogeneous equations of the form y=F(y/x)y'=F(y/x) use v=y/xv=y/x, so y=vxy=vx and y=v+xvy'=v+xv'. Equations with a shifted center, such as y=F((y2)/(x+1))y'=F((y-2)/(x+1)), may require translating coordinates before applying that idea. The point is not to memorize many named types; it is to look for algebraic structure that lowers the equation to one of the dependable forms.

Exact equations require a region condition as well as the derivative test. The equality My=NxM_y=N_x is normally used on a simply connected region where the partial derivatives are continuous. Holes in the region can produce path-dependent behavior, which is why the assumptions matter. In elementary engineering ODE problems the region is usually a rectangle or half-plane, but checking the domain prevents subtle mistakes when denominators vanish.

Integrating factors beyond the linear case exist but are not automatic. For a nonexact equation Mdx+Ndy=0M\,dx+N\,dy=0, a factor depending only on xx may be found if

MyNxN\frac{M_y-N_x}{N}

is a function of xx alone. A factor depending only on yy may be found if

NxMyM\frac{N_x-M_y}{M}

is a function of yy alone. These tests are useful, but they should be applied after the simpler classifications have been checked.

Visual

FormRecognition cueMain moveFrequent check
Separabley=g(x)h(y)y'=g(x)h(y)Put yy terms with dydy and xx terms with dxdxAdd lost equilibrium solutions
Lineary+p(x)y=r(x)y'+p(x)y=r(x)Multiply by μ=epdx\mu=e^{\int p\,dx}Left side becomes (μy)(\mu y)'
ExactMdx+Ndy=0M\,dx+N\,dy=0, My=NxM_y=N_xFind ux=Mu_x=M, uy=Nu_y=NFinal answer is implicit u=Cu=C
Bernoulliy+py=gyay'+py=gy^aUse v=y1av=y^{1-a}Exclude a=0,1a=0,1 cases
Autonomousy=f(y)y'=f(y)Phase line and equilibriaArrows match sign of ff

Worked example 1: Mixing tank with a linear equation

Problem. A tank initially contains 100100 L of water with 2020 g of salt. Brine containing 0.50.5 g/L enters at 44 L/min, and the well-mixed solution leaves at 44 L/min. Find the salt amount A(t)A(t).

Method.

  1. The volume stays 100100 L because inflow equals outflow.
  2. Rate in is
0.5gL4Lmin=2gmin.0.5\frac{\mathrm{g}}{\mathrm{L}}\cdot 4\frac{\mathrm{L}}{\mathrm{min}}=2\frac{\mathrm{g}}{\mathrm{min}}.
  1. Rate out uses tank concentration A(t)/100A(t)/100:
A(t)100gL4Lmin=A(t)25gmin.\frac{A(t)}{100}\frac{\mathrm{g}}{\mathrm{L}}\cdot 4\frac{\mathrm{L}}{\mathrm{min}}=\frac{A(t)}{25}\frac{\mathrm{g}}{\mathrm{min}}.
  1. The balance law gives
A=2A25,A(0)=20.A'=2-\frac{A}{25},\qquad A(0)=20.
  1. Put it in linear standard form:
A+125A=2.A'+\frac{1}{25}A=2.
  1. The integrating factor is
μ(t)=e(1/25)dt=et/25.\mu(t)=e^{\int (1/25)\,dt}=e^{t/25}.
  1. Multiply and integrate:
et/25A+125et/25A=2et/25,(et/25A)=2et/25,et/25A=50et/25+C.\begin{aligned} e^{t/25}A'+\frac{1}{25}e^{t/25}A &= 2e^{t/25},\\ (e^{t/25}A)' &= 2e^{t/25},\\ e^{t/25}A &= 50e^{t/25}+C. \end{aligned}
  1. Hence
A(t)=50+Cet/25.A(t)=50+Ce^{-t/25}.
  1. Use A(0)=20A(0)=20:
20=50+C,C=30.20=50+C,\qquad C=-30.

Answer.

A(t)=5030et/25.A(t)=50-30e^{-t/25}.

Check. The steady amount is 5050 g because the incoming concentration 0.50.5 g/L in a 100100 L tank corresponds to 5050 g. Since the initial amount is 2020 g, the solution increases toward 5050.

Worked example 2: Bernoulli equation reduced to linear form

Problem. Solve

y+2xy=x2y2,x>0.y'+\frac{2}{x}y=x^2y^2,\qquad x>0.

Method.

  1. This is Bernoulli with a=2a=2, p(x)=2/xp(x)=2/x, and g(x)=x2g(x)=x^2.
  2. Use
v=y1a=y1.v=y^{1-a}=y^{-1}.
  1. Differentiate:
v=y2y.v'=-y^{-2}y'.
  1. Divide the original equation by y2y^2 where y0y\ne 0:
y2y+2xy1=x2.y^{-2}y'+\frac{2}{x}y^{-1}=x^2.
  1. Substitute y2y=vy^{-2}y'=-v' and y1=vy^{-1}=v:
v+2xv=x2.-v'+\frac{2}{x}v=x^2.
  1. Multiply by 1-1:
v2xv=x2.v'-\frac{2}{x}v=-x^2.
  1. This is linear. The integrating factor is
μ(x)=e2/xdx=e2lnx=x2.\mu(x)=e^{\int -2/x\,dx}=e^{-2\ln x}=x^{-2}.
  1. Multiply:
x2v2x3v=1.x^{-2}v'-2x^{-3}v=-1.
  1. Recognize the product derivative:
(x2v)=1,x2v=x+C,v=Cx2x3.\begin{aligned} (x^{-2}v)'&=-1,\\ x^{-2}v&=-x+C,\\ v&=Cx^2-x^3. \end{aligned}
  1. Return to yy:
1y=Cx2x3=x2(Cx).\frac{1}{y}=Cx^2-x^3=x^2(C-x).

Answer.

y(x)=1x2(Cx),x>0,y(x)=\frac{1}{x^2(C-x)},\qquad x>0,

with the additional solution y=0y=0 from the original equation.

Check. Substituting v=x2(Cx)v=x^2(C-x) into v(2/x)v=x2v'-(2/x)v=-x^2 gives

2x(Cx)x22xx2(Cx)=x2,2x(C-x)-x^2-\frac{2}{x}x^2(C-x)=-x^2,

so the transformed equation is satisfied.

Code

import numpy as np
from scipy.integrate import solve_ivp

def tank_rhs(t, A):
return 2.0 - A[0] / 25.0

t_eval = np.linspace(0.0, 150.0, 301)
sol = solve_ivp(tank_rhs, (0.0, 150.0), [20.0], t_eval=t_eval)
exact = 50.0 - 30.0 * np.exp(-t_eval / 25.0)
max_error = np.max(np.abs(sol.y[0] - exact))

print(f"computed final amount = {sol.y[0, -1]:.4f} g")
print(f"exact final amount = {exact[-1]:.4f} g")
print(f"max error on grid = {max_error:.2e}")

Common pitfalls

  • Dividing by yy, 1y1-y, or another factor without checking whether it gives an equilibrium solution.
  • Using the integrating factor before the equation is in the normalized form y+p(x)y=r(x)y'+p(x)y=r(x).
  • Forgetting the constant of integration after integrating (μy)(\mu y)'.
  • Treating an implicit solution u(x,y)=Cu(x,y)=C as if it must always be solved explicitly for yy.
  • Missing interval restrictions such as x>0x\gt 0 when lnx\ln x or x1x^{-1} appears.
  • Ignoring units in models; a term with units of amount cannot be added to a term with units of amount per time.
  • Reporting only the algebraic family and skipping the initial condition. For an initial value problem, the constant must be determined and the final curve should be checked against the starting value.
  • Assuming every first-order model has a closed elementary form. Direction fields and numerical solvers are legitimate tools when recognition tests fail.

Connections