The Language of Change

A Differential Equation (DE) describes how a state changes over time.

  • Algebra solves for unknown numbers:
  • Differential Equations solve for unknown functions:

In Computer Science, we rarely solve these analytically (by hand). We solve them numerically using algorithms like Euler’s Method or Runge-Kutta.

1. Classification & Definitions

Order: The highest derivative present in the equation.

  • (First Order)
  • (Second Order)

Linearity: An ODE is linear if the dependent variable and its derivatives appear to the first power and are not multiplied together.

  • Linear:
  • Non-Linear: (Because of )

2. First Order ODEs ()

A. Separable Equations

The simplest form. We move all ‘s to one side and all ‘s to the other.

B. Linear Equations (Integrating Factor)

Standard form:

Algorithm:

  1. Calculate the Integrating Factor:
  2. Multiply the entire equation by .
  3. The Left Hand Side (LHS) collapses via the Product Rule:
  4. Integrate both sides and solve for .

C. Exact Equations

If is “exact”, then there exists a potential function such that:

Solution: .


3. Second Order Linear ODEs ()

Typically used to model springs, circuits, and vibrations. Standard Form:

Part 1: Homogeneous ()

We assume the solution is of the form . This leads to the Characteristic Equation:

Solve for roots :

  1. Distinct Real Roots ():
  2. Repeated Real Root ():
  3. Complex Roots ():

Part 2: Non-Homogeneous ()

The general solution is .

  • : The homogeneous solution (from Part 1).
  • : The “Particular” solution.

Method of Undetermined Coefficients: Guess the form of based on :

Term in Guess for
or
Polynomial

4. The Laplace Transform ()

The engineer’s “Hack”. It turns Calculus problems (derivatives) into Algebra problems.

Definition:

Key Properties:

  1. Linearity:
  2. Differentiation: Turns derivatives into multiplication by .

Common Transforms Table:

Solving IVPs with Laplace

  1. Take of both sides of the ODE.
  2. Solve algebraically for .
  3. Use Partial Fractions to decompose .
  4. Take the Inverse Laplace to find .

5. Numerical Methods (CS Approach) 💻

When an ODE is impossible to solve by hand (which is 99% of real-world cases), we approximate.

Euler’s Method

The simplest approach. We use the tangent line to step forward in time.

  • : Step size (e.g., 0.01).
  • Error: (Global error is proportional to step size).

Runge-Kutta 4 (RK4)

The industry standard for simulations (Game physics, orbital mechanics). It samples the slope at 4 points to predict the next step.

Where:

Error: . Much more precise than Euler.


Linked Notes