1642  Mathematical Foundations for IoT

NoteKey Takeaway

In one sentence: You don’t need to be a mathematician to succeed in IoT engineering - focus on understanding what each concept means and when to apply it, not memorizing proofs.

Remember this rule: When you encounter a formula in IoT documentation, use this appendix to understand the intuition behind it and see practical examples before attempting implementation.

TipMVU: Mathematics for IoT Engineers

Core Concept: IoT engineering relies on a handful of mathematical tools - derivatives for measuring change, logarithms for managing large ranges, probability for handling uncertainty, and linear algebra for sensor fusion.

Why It Matters: Understanding these foundations lets you read datasheets, interpret signal measurements, configure PID controllers, and estimate battery life without guessing.

Key Takeaway: You do not need to derive formulas from scratch - focus on recognizing which tool applies to each problem and understanding the intuition behind the math.

1642.1 Purpose of This Appendix

This appendix provides the mathematical background needed to understand advanced IoT concepts. Unlike a mathematics textbook, we focus on intuition and application rather than rigorous proofs. Each section explains:

  1. What the mathematical concept is
  2. Why it matters for IoT
  3. How to apply it (with examples)

You don’t need to be a mathematician to succeed in IoT engineering. These foundations give you the vocabulary and intuition to understand technical documentation and make informed design decisions.


1642.2 A. Calculus Concepts for IoT

1642.2.1 A.1 Rates of Change (Derivatives)

TipThe Core Idea

A derivative measures how fast something is changing at any instant. In IoT, we constantly deal with changing quantities: temperature rising, battery depleting, signals fluctuating.

Notation: \(\frac{dx}{dt}\) means “the rate at which x changes with respect to time t”

IoT Applications:

Scenario What’s Changing Derivative Meaning
Temperature monitoring Temperature (T) \(\frac{dT}{dt}\) = heating/cooling rate (°C/second)
Battery drain Charge (Q) \(\frac{dQ}{dt}\) = current flow (Amperes)
Vehicle tracking Position (x) \(\frac{dx}{dt}\) = velocity (m/s)
Signal processing Voltage (V) \(\frac{dV}{dt}\) = rate of voltage change

Practical Example - PID Controller:

The PID formula uses derivatives: \[P(t) = K_p \cdot e(t) + K_i \cdot \int e(t)dt + K_d \cdot \frac{de(t)}{dt}\]

  • P term: Current error (how far off are we?)
  • D term (\(\frac{de}{dt}\)): How fast is the error changing? (prevents overshooting)
  • I term: Accumulated error over time (corrects persistent drift)

Intuition: The derivative term is like a driver who slows down when approaching a stop sign - you react to how fast you’re approaching, not just how far away you are.

1642.2.2 A.2 Accumulation (Integrals)

TipThe Core Idea

An integral adds up many small pieces to get a total. Think of it as “continuous summation.”

Notation: \(\int f(x)dx\) means “sum up all the tiny pieces of f(x)”

IoT Applications:

Scenario What We’re Summing Result
Energy consumption Power × time Total energy used (Joules)
Data transfer Bits per second × time Total data transferred (bytes)
Sensor noise Small random fluctuations Average reading (smoothing)
Battery capacity Current × time Charge used (mAh)

Practical Example - Energy Budget:

Total energy consumed by an IoT device: \[E_{total} = \int_0^T P(t) \, dt\]

If power varies during operation: - Active mode: \(P_{active} = 50mW\) for 10ms - Sleep mode: \(P_{sleep} = 0.01mW\) for 990ms

\[E_{cycle} = (50mW \times 10ms) + (0.01mW \times 990ms) = 0.5mJ + 0.0099mJ \approx 0.51mJ\]

Intuition: Integration is like measuring water in a tank by tracking how fast it fills over time, even if the flow rate changes.

1642.2.3 A.3 The Derivative-Integral Relationship

Derivatives and integrals are inverses: - Derivative: Tells you the rate of change - Integral: Tells you the accumulated total

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#fff', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085', 'secondaryColor': '#E67E22', 'tertiaryColor': '#7F8C8D'}}}%%
flowchart LR
    P["Position<br/>(meters)"]
    V["Velocity<br/>(m/s)"]
    A["Acceleration<br/>(m/s²)"]

    A -->|"integrate"| V
    V -->|"integrate"| P
    P -->|"d/dt differentiate"| V
    V -->|"d/dt differentiate"| A

Figure 1642.1

In sensor fusion, we often: - Integrate accelerometer data to get velocity - Integrate velocity to get position - Differentiate position to get velocity


1642.3 B. Exponential and Logarithmic Functions

1642.3.1 B.1 Exponential Growth and Decay

TipThe Core Idea

Exponential functions describe processes where change is proportional to the current value. Things grow (or decay) faster when there’s more of them.

The exponential function: \(y = e^x\) where \(e \approx 2.718\)

IoT Applications:

Phenomenon Formula Description
Capacitor discharge \(V(t) = V_0 \cdot e^{-t/\tau}\) Voltage decays exponentially
Signal attenuation \(P = P_0 \cdot e^{-\alpha d}\) Power decreases with distance
Sensor warm-up \(T(t) = T_{final}(1 - e^{-t/\tau})\) Approaches target exponentially
Battery self-discharge \(Q(t) = Q_0 \cdot e^{-\lambda t}\) Charge slowly leaks away

Time Constant (τ): - After \(1\tau\): Value drops to 37% of initial (\(e^{-1} \approx 0.37\)) - After \(3\tau\): Value drops to 5% of initial - After \(5\tau\): Value drops to 0.7% (essentially zero for practical purposes)

Practical Example - RC Time Constant:

A sensor with a 100Ω resistor and 10µF capacitor: \[\tau = R \times C = 100\Omega \times 10\mu F = 1ms\]

This sensor can respond to signals changing up to ~1000 Hz.

1642.3.2 B.2 Logarithms

TipThe Core Idea

A logarithm asks: “What power do I raise the base to, to get this number?” Logarithms compress large ranges into manageable scales.

Definition: If \(b^x = y\), then \(\log_b(y) = x\)

Common bases: - \(\log_{10}\) (common log) - used in dB calculations - \(\ln\) or \(\log_e\) (natural log) - used in signal processing - \(\log_2\) (binary log) - used in information theory (bits)

IoT Applications:

1. Decibels (dB) - Compress power ratios: \[dB = 10 \log_{10}\left(\frac{P_{out}}{P_{in}}\right)\]

Power Ratio dB Value
1× (no change) 0 dB
2× (double) +3 dB
10× +10 dB
100× +20 dB
0.5× (half) -3 dB
0.1× -10 dB

2. Shannon Capacity - Maximum data rate: \[C = B \log_2(1 + SNR)\]

Where: - \(C\) = channel capacity (bits/second) - \(B\) = bandwidth (Hz) - \(SNR\) = signal-to-noise ratio

Why logarithm? Doubling SNR doesn’t double capacity - you get diminishing returns.

3. dBm (Power in milliwatts): \[dBm = 10 \log_{10}(P_{mW})\]

Power dBm
1 mW 0 dBm
10 mW 10 dBm
100 mW 20 dBm
0.001 mW (1 µW) -30 dBm

1642.4 C. Linear Algebra Basics

1642.4.1 C.1 Vectors

TipThe Core Idea

A vector is an ordered list of numbers representing multiple related quantities. In IoT, sensors often produce vector outputs (e.g., 3-axis accelerometer gives [x, y, z]).

Notation: \(\vec{v} = \begin{bmatrix} x \\ y \\ z \end{bmatrix}\) or simply \([x, y, z]\)

IoT Applications:

Data Type Vector Representation
3-axis accelerometer \([a_x, a_y, a_z]\) in g-force
GPS position \([latitude, longitude, altitude]\)
RGB color \([red, green, blue]\) values 0-255
IMU (9-axis) \([a_x, a_y, a_z, g_x, g_y, g_z, m_x, m_y, m_z]\)

Vector Operations:

Magnitude (Length): How “big” is the vector? \[|\vec{v}| = \sqrt{x^2 + y^2 + z^2}\]

Example: Accelerometer reads \([0.5, 0.3, 0.8]g\) \[|\vec{a}| = \sqrt{0.5^2 + 0.3^2 + 0.8^2} = \sqrt{0.98} \approx 0.99g\]

This tells us the total acceleration magnitude (useful for fall detection).

1642.4.2 C.2 Matrices

TipThe Core Idea

A matrix is a 2D array of numbers. Matrices transform vectors - rotate them, scale them, or combine multiple measurements.

Notation: \[M = \begin{bmatrix} a & b \\ c & d \end{bmatrix}\]

IoT Applications:

1. Coordinate Transformation:

Rotating sensor data to align with a reference frame: \[\begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}\]

2. Kalman Filter State:

State vector might be \([position, velocity, acceleration]\): \[\vec{x} = \begin{bmatrix} p \\ v \\ a \end{bmatrix}\]

State transition predicts next state: \[\vec{x}_{k+1} = F \cdot \vec{x}_k\]

3. Covariance Matrix:

Describes uncertainty in measurements: \[P = \begin{bmatrix} \sigma_x^2 & \sigma_{xy} \\ \sigma_{xy} & \sigma_y^2 \end{bmatrix}\]

Diagonal elements: Variance (uncertainty) in each variable Off-diagonal: How variables correlate (change together)

1642.4.3 C.3 Matrix Multiplication

NoteQuick Rule

To multiply matrix A (m×n) by matrix B (n×p), the inner dimensions must match. Result is (m×p).

Example: Transforming a 3D point \[\begin{bmatrix} 2 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 2 \end{bmatrix} \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix} = \begin{bmatrix} 2 \\ 4 \\ 6 \end{bmatrix}\]

This scales the vector by 2 in all directions.


1642.5 D. Probability and Statistics

1642.5.1 D.1 Basic Probability

TipThe Core Idea

Probability quantifies uncertainty. In IoT, sensor readings are never perfect - probability helps us reason about noise, errors, and reliability.

Key Concepts:

Term Definition IoT Example
Probability P(A) Chance of event A (0 to 1) P(packet loss) = 0.02
Expected Value E[X] Average outcome Average sensor reading
Variance Var(X) Spread around average Noise level
Standard Deviation σ √Variance ±σ covers 68% of readings

Practical Example - Sensor Reliability:

If a sensor has 99.9% uptime: - P(working) = 0.999 - P(failure) = 0.001

For 100 sensors, expected failures = 100 × 0.001 = 0.1 per unit time

1642.5.2 D.2 Gaussian (Normal) Distribution

TipThe Core Idea

The Gaussian distribution (bell curve) describes random noise in most physical systems. It’s characterized by mean (μ) and standard deviation (σ).

\[p(x) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}\]

Properties: - 68% of values within μ ± 1σ - 95% of values within μ ± 2σ - 99.7% of values within μ ± 3σ

IoT Application - Sensor Noise:

A temperature sensor with: - Mean reading: μ = 25.0°C - Noise: σ = 0.5°C

95% of readings will be between 24.0°C and 26.0°C.

1642.5.3 D.3 Sensor Fusion: Combining Measurements

When you have two noisy measurements of the same thing, the optimal combination is:

\[x_{combined} = \frac{\sigma_2^2 \cdot x_1 + \sigma_1^2 \cdot x_2}{\sigma_1^2 + \sigma_2^2}\]

Intuition: Weight each measurement inversely by its uncertainty. Trust the more precise sensor more.

Example: - GPS says position is 100m (σ = 10m) - Accelerometer integration says 95m (σ = 5m)

\[x_{combined} = \frac{25 \times 100 + 100 \times 95}{100 + 25} = \frac{2500 + 9500}{125} = 96m\]

The combined estimate is closer to the accelerometer (more precise).


1642.6 E. Modular Arithmetic for Cryptography

1642.6.1 E.1 The Modulo Operation

TipThe Core Idea

Modular arithmetic is “clock arithmetic.” After reaching a maximum value, numbers wrap around to zero.

Notation: \(a \mod n\) = remainder when a is divided by n

Examples: - \(7 \mod 5 = 2\) (7 = 1×5 + 2) - \(25 \mod 7 = 4\) (25 = 3×7 + 4) - \(12 \mod 12 = 0\) (clock wraps at midnight)

1642.6.2 E.2 Why Modular Arithmetic for Cryptography?

Key Property: Easy to compute forward, hard to reverse.

Example - Discrete Logarithm:

Given: \(g = 5\), \(p = 23\)

Forward (easy): Calculate \(5^7 \mod 23\) \[5^7 = 78125 \mod 23 = 17\]

Reverse (hard): Given 17, find x where \(5^x \mod 23 = 17\)

This “trapdoor” property enables public-key cryptography.

1642.6.3 E.3 Diffie-Hellman Key Exchange

Two IoT devices can agree on a shared secret over an insecure channel:

Mermaid diagram

Mermaid diagram
Figure 1642.2: Diffie-Hellman key exchange between two IoT devices

%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#2C3E50', 'primaryTextColor': '#2C3E50', 'primaryBorderColor': '#16A085', 'lineColor': '#16A085'}}}%%
flowchart TB
    subgraph PUBLIC["Public Information (Eavesdropper Sees)"]
        SHARED["🟡 Shared Base Color<br/>Yellow (g=5, p=23)"]
        MSG_A["🟠 A's Public Message<br/>Orange = Yellow + Red"]
        MSG_B["🟢 B's Public Message<br/>Green = Yellow + Blue"]
    end

    subgraph DEV_A["Device A (Private)"]
        SECRET_A["🔴 Secret Color: Red<br/>(a = 6, private)"]
        COMPUTE_A["🟤 Compute: Green + Red<br/>= Brown (shared secret)"]
    end

    subgraph DEV_B["Device B (Private)"]
        SECRET_B["🔵 Secret Color: Blue<br/>(b = 15, private)"]
        COMPUTE_B["🟤 Compute: Orange + Blue<br/>= Brown (shared secret)"]
    end

    SHARED --> MSG_A
    SHARED --> MSG_B
    SECRET_A --> MSG_A
    SECRET_B --> MSG_B
    MSG_B --> COMPUTE_A
    MSG_A --> COMPUTE_B
    SECRET_A --> COMPUTE_A
    SECRET_B --> COMPUTE_B

    style PUBLIC fill:#F5F5F5,stroke:#7F8C8D,stroke-width:2px
    style DEV_A fill:#E8F4F8,stroke:#16A085,stroke-width:2px
    style DEV_B fill:#E8F4F8,stroke:#16A085,stroke-width:2px
    style SHARED fill:#F1C40F,stroke:#2C3E50,stroke-width:1px
    style MSG_A fill:#E67E22,stroke:#2C3E50,stroke-width:1px
    style MSG_B fill:#27AE60,stroke:#2C3E50,stroke-width:1px
    style SECRET_A fill:#E74C3C,stroke:#2C3E50,stroke-width:1px,color:#fff
    style SECRET_B fill:#3498DB,stroke:#2C3E50,stroke-width:1px,color:#fff
    style COMPUTE_A fill:#8B4513,stroke:#2C3E50,stroke-width:2px,color:#fff
    style COMPUTE_B fill:#8B4513,stroke:#2C3E50,stroke-width:2px,color:#fff

Figure 1642.3: Alternative View: Paint Mixing Analogy - This diagram explains Diffie-Hellman using a color mixing analogy. Both devices start with shared public Yellow. Device A mixes with secret Red to create Orange. Device B mixes with secret Blue to create Green. They exchange Orange and Green publicly. A then adds Red to Green, B adds Blue to Orange - both get the same Brown (shared secret). The eavesdropper sees Yellow, Orange, and Green but cannot “unmix” colors to find the secrets. In math terms: mixing colors is easy (modular exponentiation), but unmixing is computationally hard (discrete logarithm). This is why Diffie-Hellman works for IoT key exchange.

An eavesdropper sees only 8 and 19 - computing the shared secret requires solving the discrete logarithm problem (computationally infeasible for large numbers).


1642.7 F. Complex Numbers for Signal Processing

1642.7.1 F.1 What Are Complex Numbers?

TipThe Core Idea

Complex numbers extend real numbers to include \(i = \sqrt{-1}\). They’re essential for representing signals that have both amplitude and phase.

Form: \(z = a + bi\) - \(a\) = real part - \(b\) = imaginary part

Alternative (Polar) Form: \(z = r \cdot e^{i\theta}\) - \(r\) = magnitude (amplitude) - \(\theta\) = phase angle

1642.7.2 F.2 Why Complex Numbers in IoT?

1. Representing Sinusoidal Signals:

A sensor reading: \(v(t) = A \cos(\omega t + \phi)\)

Using Euler’s formula: \(e^{i\theta} = \cos\theta + i\sin\theta\)

We can write: \(v(t) = \text{Re}[A \cdot e^{i(\omega t + \phi)}]\)

2. Fourier Transform:

Converts time-domain signals to frequency-domain: \[X(f) = \int_{-\infty}^{\infty} x(t) \cdot e^{-i2\pi ft} \, dt\]

The result is complex: - Magnitude \(|X(f)|\) tells you “how much” of each frequency - Phase \(\angle X(f)\) tells you “when” each frequency component peaks

3. I/Q Signals in Radio:

LoRa and other radios use I/Q (In-phase/Quadrature) representation: - I = real part of signal - Q = imaginary part of signal

This allows representing any modulation scheme.

1642.7.3 F.3 Complex Number Operations

Operation Formula Signal Processing Meaning
Addition \((a+bi) + (c+di) = (a+c) + (b+d)i\) Superimposing signals
Magnitude \(|a+bi| = \sqrt{a^2+b^2}\) Signal amplitude
Phase \(\angle(a+bi) = \arctan(b/a)\) Signal timing
Multiplication Magnitudes multiply, phases add Mixing/modulation

1642.8 G. Information Theory Basics

1642.8.1 G.1 Bits and Entropy

TipThe Core Idea

Entropy measures information content or uncertainty. More unpredictable data requires more bits to represent.

Entropy formula: \[H = -\sum_i p_i \log_2(p_i)\]

Where \(p_i\) is the probability of each outcome.

Example - Sensor Alarm: - Alarm triggers 1% of the time - \(H = -(0.01 \log_2 0.01 + 0.99 \log_2 0.99)\) - \(H = -(0.01 \times -6.64 + 0.99 \times -0.014) = 0.08\) bits

The alarm provides only 0.08 bits of information per reading (very predictable).

1642.8.2 G.2 Shannon Capacity

The maximum rate at which information can be reliably transmitted:

\[C = B \log_2(1 + SNR)\]

Practical Implications:

SNR Capacity (per Hz of bandwidth)
1 (0 dB) 1 bit/s/Hz
3 (5 dB) 2 bit/s/Hz
7 (8.5 dB) 3 bit/s/Hz
15 (12 dB) 4 bit/s/Hz
31 (15 dB) 5 bit/s/Hz

Key Insight: To double capacity, you need to roughly quadruple SNR. This explains why LoRa trades data rate for range (lower SNR = lower rate but still works).


1642.9 H. Quick Reference Card

1642.9.1 Essential Formulas for IoT

1642.9.1.1 Signal Processing

Formula Expression
Nyquist Rate \(f_{sample} \geq 2 \times f_{max}\)
Shannon Capacity \(C = B \times \log_2(1 + SNR)\)
dB conversion \(dB = 10 \times \log_{10}(P_2/P_1)\)
dBm from mW \(dBm = 10 \times \log_{10}(P_{mW})\)

1642.9.1.2 Wireless

Formula Expression
Free Space Loss \(FSPL = 20\log_{10}(d) + 20\log_{10}(f) + 20\log_{10}(4\pi/c)\)
Link Budget \(P_{rx} = P_{tx} + G_{tx} + G_{rx} - L_{path}\)
Path Loss (approx) \(L \propto d^n\) (n = 2 free space, 3-4 urban)

1642.9.1.3 Electronics

Formula Expression
Ohm’s Law \(V = I \times R\)
Power \(P = V \times I = I^2R = V^2/R\)
RC Time Constant \(\tau = R \times C\)
Capacitor Voltage \(V(t) = V_0 \times e^{-t/\tau}\)

1642.9.1.4 Battery Life

Formula Expression
Average Current \(I_{avg} = (I_{active} \times D) + (I_{sleep} \times (1-D))\)
Battery Life \(Hours = mAh / mA_{average}\)

1642.9.1.5 Sensor Fusion

Formula Expression
Weighted Average \(x = (\sigma_2^2 \times x_1 + \sigma_1^2 \times x_2) / (\sigma_1^2 + \sigma_2^2)\)
Combined Variance \(\sigma^2 = (\sigma_1^2 \times \sigma_2^2) / (\sigma_1^2 + \sigma_2^2)\)

1642.9.1.6 Probability

Formula Expression
Gaussian 68-95-99 \(\mu \pm 1\sigma\) (68%), \(\mu \pm 2\sigma\) (95%), \(\mu \pm 3\sigma\) (99.7%)
Expected Value \(E[X] = \sum(x \times P(x))\)

1642.11 Summary

This appendix covered the mathematical foundations used throughout the IoT textbook:

Topic Key Concept Primary Use
Calculus Rates & accumulation PID control, energy budgets
Exponentials Growth/decay Signal attenuation, battery life
Logarithms Compression dB scales, Shannon capacity
Linear Algebra Vectors, matrices Sensor fusion, Kalman filter
Probability Uncertainty Noise modeling, reliability
Modular Arithmetic Wraparound math Cryptography
Complex Numbers Amplitude + phase Signal processing, radio
Information Theory Bits, entropy Channel capacity, compression

1642.12 Knowledge Check

  1. Decibels (dB) are primarily a:

dB scales compress large ratios using logarithms (e.g., 10·log10(P2/P1) for power ratios), which is useful in RF and signal analysis.

  1. In an RC circuit, the time constant is defined as:

The RC time constant τ = R·C sets the exponential charging/discharging rate (e.g., V(t) = V0·e^(−t/τ) for discharge).

  1. The expected value E[X] of a discrete random variable is computed by:

Expected value weights each outcome by its probability, providing the long-run average of X under repeated trials.

  1. Modular arithmetic is most directly relevant to:

Many cryptographic schemes rely on arithmetic over finite fields or modular rings (e.g., operations mod a prime), making modular arithmetic foundational for crypto.

  1. A signal’s power drops from 100 mW to 1 mW. What is the loss in dB?

Loss in dB = 10·log₁₀(P₂/P₁) = 10·log₁₀(1/100) = 10·log₁₀(0.01) = 10·(-2) = -20 dB (or 20 dB loss). Each factor of 10 in power = 10 dB. Factor of 100 = 20 dB.

  1. The Fourier transform converts a signal from:

The Fourier transform decomposes a time-domain signal into its frequency components. This reveals what frequencies are present in a sensor signal (e.g., 60 Hz interference, motor vibration harmonics).

  1. Shannon’s channel capacity formula C = B·log₂(1 + SNR) shows that doubling bandwidth:

Shannon’s formula shows capacity is linear with bandwidth (B) but logarithmic with SNR. Doubling bandwidth doubles capacity. To double capacity via SNR alone would require exponentially more power—this is why bandwidth is precious.

  1. An IoT sensor samples at 1000 Hz and applies a moving average filter. After 5 samples, what is the maximum frequency that can be accurately represented without aliasing?

The Nyquist limit is half the sampling rate: 1000/2 = 500 Hz. The moving average filter doesn’t change this—it’s a low-pass filter that reduces high-frequency content, but the fundamental aliasing limit is set by the sample rate. Signals above 500 Hz will alias.

1642.13 What’s Next

With these mathematical foundations, you’re equipped to understand:

Return to the Main Appendix for quick reference tables and formulas.