Always free. For everyone.
Course outline
Module 02 of 20 · Foundations

Build the mathematical toolkit

Use exponentials, complex numbers, integration, and numerical error. This module has 3 lessons and takes about 2h 25m. Each lesson has a practice exercise that runs real Python in your browser and a short quiz.

Start module 02 in the Learning Lab
LESSON 1 OF 3

Exponentials and complex poles

35 minControl engineering
WHAT YOU WILL DO

Connect pole location to decay and oscillation.

The scalar differential equation dx/dt = a*x has solution x(t) = x(0)*exp(a*t). A negative a produces decay. For a = -1/tau, tau is the time constant, and the initial value falls to about 36.8% after tau seconds.

A complex pole s = sigma + j*omega gives exp(sigma*t) multiplied by a sinusoid. Sigma sets growth or decay; omega sets angular frequency in rad/s. Frequency in hertz is omega/(2*pi). Real systems have conjugate pole pairs.

For poles -2 +/- 3j, the oscillation envelope decays like exp(-2*t) while the period is 2*pi/3 seconds. The complex magnitude sqrt(2^2+3^2) is the natural frequency, not the damped oscillation frequency.

See it in action

example.pyPython 3
import cmath, math
pole = complex(-2, 3)
print('Envelope at 1 s:', math.exp(pole.real))
print('Period:', 2*math.pi/abs(pole.imag), 's')
print('Mode at 1 s:', cmath.exp(pole))
Keep this in mind

Distinguish natural frequency, damped frequency, and decay rate.

LESSON 2 OF 3

Derivatives, integrals, and sampled data

35 minControl engineering
WHAT YOU WILL DO

Approximate rate and accumulated error from measurements.

A derivative measures rate of change. With evenly spaced samples, (y[k]-y[k-1])/dt estimates the slope over one interval. Differentiation amplifies rapid measurement noise, especially when dt is small.

An integral measures accumulation. A left rectangle sum uses sum(e[:-1])*dt for data sampled at both ends of a time interval. The trapezoid rule averages adjacent samples, then multiplies by dt. Both require clear time units.

For a ramp e(t)=t from 0 to 2 seconds, the exact integral is 2. A trapezoid rule is exact for this straight line. Its integral has units of error times seconds, which is why integral controller gains have different units from proportional gains.

See it in action

example.pyPython 3
import numpy as np
t = np.linspace(0, 2, 11)
e = t
dt = t[1]-t[0]
slopes = np.diff(e)/dt
area = np.sum((e[:-1]+e[1:])*0.5)*dt
print('Slopes:', slopes)
print('Accumulated error:', area)
Keep this in mind

Always count intervals and include dt in integration and differentiation.

LESSON 3 OF 3

Practical: test your numerical solver

75 minControl engineering
WHAT YOU WILL DO

Separate numerical instability from unstable physical dynamics.

For dx/dt = -2*x, Euler gives x[k+1]=(1-2*dt)*x[k]. The true solution is stable, but the numerical recursion is stable only if abs(1-2*dt)<1, which means 0<dt<1.

At dt=0.75 the numerical solution alternates sign while decaying, even though the true solution never changes sign. At dt=1.1 it grows. These are errors in the numerical method, not new physical behaviour.

Compare against an analytical solution whenever possible. Then halve the step and check convergence. For larger systems, use a suitable integration method and tolerances instead of assuming Euler is accurate.

GUIDED PRACTICAL · 75 MIN

Your experiment plan

Use the browser editor or the downloadable notebook. All plant data are simulated. Keep a notebook with parameters, predictions, results, and units.

  1. Plot analytical and Euler responses for three step sizes.
  2. Try dt=0.75 and 1.1 for ten steps and explain the sign changes and growth.
  3. Complete the checked refinement experiment.
  4. Choose a step for later labs and justify it using an error tolerance.

What to hand in

  • A convergence table.
  • A plot distinguishing physical and numerical behaviour.
  • A stated simulation step and tolerance.
Reflect on your results

Which assumption matters most? Describe one result that surprised you and one experiment that would test your explanation.

The automatic exercise checks the core code behaviour. Review observations and written deliverables yourself or with a mentor.

See it in action

example.pyPython 3
import math
for dt in [0.5, 0.25, 0.125]:
    x = 1.0
    for _ in range(round(2/dt)):
        x += dt*(-2*x)
    print(dt, x, 'absolute error:', abs(x-math.exp(-4)))
Keep this in mind

A stable plant can have an unstable numerical simulation.

ABOUT THE LEARNING LAB

Free, open and run by a nonprofit.

This page is part of Control Engineering, a free course of 20 modules and 60 lessons in the engineering.fit( ) Learning Lab. The Learning Lab is built and run by engineering.fit( ), a nonprofit founded by Abdullateef Opeyemi Bakare that helps African engineering students gain research experience. You do not need an account or pay a fee to learn.

Course outline · Project lab · Visit engineering-fit.org