10–12 min read Number Theory & Algebraic Foundations Lesson 2 / 32
Part 1 — Mathematical Foundations

Lesson 14.2 — Numbers, Variables & Mathematical Expressions

The Core Language of Math: Classification of numbers, algebraic variables, order of operations, and computational applications

What We Will Learn

By the end of this lesson, you will master the foundational mechanics of mathematics:

  • Representing unknown quantities in real-world engineering via Variables
  • The hierarchy of numbers: Natural, Whole, Integer, Rational, Irrational, Real
  • Core operations: Addition, Subtraction, Multiplication, Division, Powers, Modulo
  • Precise conceptual boundaries between Variables and Constants
  • Anatomy of an Expression: Terms, Coefficients, Constants, and Operators
  • Order of Operations (PEMDAS/BODMAS) operator precedence rules
  • Mathematical equality (=) vs. Programming memory assignment (=)
  • Machine Learning linear predictions: Deconstructing y = wx + b

1 Introduction: How the Language of Mathematics Works

We interact with numbers constantly in our everyday routines: reading a price tag, checking timestamps, calculating velocity, or measuring server latency. But in Computer Science and Artificial Intelligence, operating solely on fixed static numbers is rarely sufficient. We need systematic tools to represent unknown quantities, define dynamic relationships, and formulate real-world constraints into computable models.

Real-World Scenario: Calculating Total Purchase Cost

Suppose a stationery shop sells pens at $10 each. Before arriving at the checkout counter, the exact quantity of pens you intend to purchase is unknown.

If you purchase 1 pen, the cost is $10. If you buy 5 pens, the cost is $50. If you buy 20 pens, it is $200. Rather than recalculating from scratch for every possible scenario, we synthesize an invariant mathematical rule:

Total Cost = 10 × x   (written compactly as 10x)

Here, x represents a Variable. Whenever x is supplied with a specific integer, the exact total cost is evaluated deterministically.

This elementary example encapsulates the three cornerstone pillars of mathematical discourse:

1. Numbers

Quantify concrete magnitudes, counts, or physical metrics (e.g., $10).

2. Variables

Hold placeholders for unknown, fluctuating, or parametric quantities (e.g., x pens).

3. Expressions

Meaningful combinations of numbers, variables, and operators (e.g., 10x).

2 What Are Numbers? The Classification of Number Systems

A number is a fundamental abstraction used to quantify counts, measure physical properties, identify orders, and specify coordinates. In mathematics, numbers are partitioned into hierarchical sets, which directly mirror primitive data types in computer hardware and programming languages.

ℕ 2.1 Natural Numbers (Counting Numbers)

Discrete Counts

The positive integers used for counting discrete entities: 1, 2, 3, 4, 5, 6, .... When specifying loop iteration counts, thread pools, or page numbers, Natural Numbers are used.

𝕎 2.2 Whole Numbers (Non-Negative Integers)

Natural Numbers + Zero

Augmenting natural numbers with zero (0): 0, 1, 2, 3, 4, .... Array indexing in C, Python, and JavaScript begins at 0, which corresponds to whole numbers.

ℤ 2.3 Integers

Signed Whole Numbers

All whole numbers and their negative counterparts: ..., -3, -2, -1, 0, 1, 2, 3, .... Negative numbers represent direction, deficit, temperature below freezing (-5°C), or financial debt.

ℚ 2.4 Rational Numbers

Quotients of Integers

Any number that can be expressed as a ratio of two integers a / b (where b ≠ 0). Examples: 1/2, 3/4, -5/2, 7 (since 7 = 7/1). Terminating and recurring decimals such as 0.5 (1/2) and 0.333... (1/3) are strictly rational.

𝕀 2.5 Irrational Numbers

Non-Repeating Infinite Decimals

Real numbers that cannot be represented as simple fractions. Their decimal expansions are infinite and never repeat a predictable periodic pattern: √2 (≈ 1.41421...), √3, and π (≈ 3.14159...).

ℝ 2.6 Real Numbers

Union of Rational & Irrational

The continuum of all values that can be mapped onto the continuous Number Line. Machine learning feature vectors, weights, biases, and continuous probability distributions reside in real number spaces (ℝn).

Set Inclusion Hierarchy

Natural (ℕ) ⊂ Whole (𝕎) ⊂ Integers (ℤ) ⊂ Rational (ℚ) ⊂ Real Numbers (ℝ)

3 Fundamental Arithmetic Operations

Every computational algorithm executed on a CPU's Arithmetic Logic Unit (ALU) or a GPU tensor core fundamentally reduces to a combination of elementary arithmetic operations:

Addition — + Addends → Sum

5 + 3 = 8. The operands are Addends and the resulting outcome is the Sum.

Subtraction — - Minuend - Subtrahend

10 - 4 = 6. 10 is the Minuend, 4 is the Subtrahend, and 6 is the Difference.

Multiplication — × or * Iterated Addition

4 × 3 = 12 (4 + 4 + 4 = 12). Used billions of times per second in matrix transformations and neural network inference.

Division — ÷ or / Division by 0 is undefined

12 ÷ 3 = 4. Dividend (12), Divisor (3), and Quotient (4). Division by zero is undefined in mathematics and causes fatal runtime exceptions in code.

Exponentiation — ab or ** Repeated Multiplication

23 = 2 × 2 × 2 = 8. 2 is the Base and 3 is the Exponent (Power).

Modulo / Remainder — % Core CS Operator

17 ÷ 5 = 3 (remainder 2). In code: 17 % 5 = 2. Vital for hash indexing, parity checks, and circular buffer algorithms.

4 Variables and Constants

A Variable is an algebraic symbol that represents an unknown or changing quantity. In algebra, variables are conventionally denoted by letters such as x, y, z, a, b, t.

Books Purchased (Variable x) Computation ($200 × x) Total Payable Price
1200 × 1$200
2200 × 2$400
5200 × 5$1,000
10200 × 10$2,000

Variable

Values that vary across scenarios. In the physical equation for distance d = 60t, time t is an independent variable. Changing time changes the resulting distance d.

Constant

Values that remain fixed throughout an analysis. In the linear expression y = 5x + 10, 5 and 10 are constants because their magnitudes never change regardless of the value assigned to x.

5 What Is a Mathematical Expression?

A Mathematical Expression is any well-formed combination of numbers, variables, and operators that represents a computational value.

Anatomy of an Algebraic Expression
5x + 3
5 Coefficient
x Variable
+ Operator
3 Constant Term

Coefficient: A numerical factor multiplied by a variable. In 5x, 5 is the coefficient of x. If no number precedes a variable (such as x), the implicit coefficient is 1.

Term: An individual constituent of an expression delineated by addition or subtraction operators. In 5x + 3, 5x is the variable term and 3 is the constant term.

Evaluating an Expression

Consider the expression E = 3x + 5:

  • If x = 4: E = 3(4) + 5 = 12 + 5 = 17
  • If x = 2: E = 3(2) + 5 = 6 + 5 = 11
  • If x = 0: E = 3(0) + 5 = 0 + 5 = 5

6 Order of Operations: The PEMDAS / BODMAS Hierarchy

When an expression contains multiple chained operators, unambiguous evaluation requires universally agreed precedence rules.

The Left-to-Right Blind Trap:

2 + 3 × 4

Adding first: (2 + 3) × 4 = 5 × 4 = 20 (Incorrect!)

Standard Mathematical Evaluation:

2 + 3 × 4

Multiplication takes precedence: 2 + (3 × 4) = 2 + 12 = 14 (Correct!)

Operator Precedence Pipeline (PEMDAS / BODMAS)

  1. 1. P Parentheses / Brackets: Evaluate internal sub-expressions first.
  2. 2. E Exponents / Powers: Calculate squares, square roots, and powers next.
  3. 3. MD Multiplication & Division: Equal priority; evaluated from left to right.
  4. 4. AS Addition & Subtraction: Equal priority; evaluated from left to right.
Precedence Example: 20 ÷ 5 × 2

Because division and multiplication share equal precedence, evaluate left to right:

= (20 ÷ 5) × 2

= 4 × 2 = 8

7 Mathematical Variables vs. Programming Variables

While the term Variable is shared between pure mathematics and computer science, their conceptual models differ fundamentally:

Criterion Mathematical Variable Programming Variable
Core Nature An unknown, static, or symbolic value in an equation A named memory address in physical RAM storing state
Meaning of '=' Propositional equality (both sides are permanently equal) Assignment statement (assign value of RHS to memory at LHS)
Statement 'x = x + 1' Mathematically false and contradictory (has no solution) Routine code pattern: increments the stored integer by 1
Domain / Typing Defined by mathematical sets (e.g., x ∈ ℝ) Constrained by machine types (int32, float64, string)

8 Mathematical Expressions in Production Software & AI

Mathematical expressions form the exact computational specifications executed across modern software and machine learning infrastructure:

1. Commercial Revenue

R = p × q

Unit price p = $500 and volume q = 20 units yields gross revenue R = 500 × 20 = $10,000.

2. Statistical Mean

Mean = (x₁ + x₂ + ... + xₙ) / n

Test results of 70, 80, 90 evaluate to Mean = (70 + 80 + 90) / 3 = 240 / 3 = 80.

3. Machine Learning Prediction

y = wx + b

Given input feature x = 4, learned weight w = 2, and bias b = 3: the model predicts y = 2(4) + 3 = 11.

Hands-on Laboratory

🎮 Interactive Numbers, Variables & Expressions Workbench

Switch between the three interactive tabs below to test number classifications, step through PEMDAS operator precedence, and explore the linear regression equation behind AI.

Examine Which Sets Contain a Given Number

Select any preset number below to see which mathematical sets classify it.

Test Number:
Natural (ℕ) ✓ Included
Whole (𝕎) ✓ Included
Integer (ℤ) ✓ Included
Rational (ℚ) ✓ Included
Irrational (𝕀) ✗ Not Included
Real (ℝ) ✓ Included
Analysis: 5 is a counting Natural Number (N). By definition, it is also a Whole number (W), an Integer (Z), a Rational number (Q, as 5/1), and a Real number (R).

Lesson Summary

  • ✓ Numbers serve as universal quantifiers; Natural, Whole, Integer, Rational, Irrational, and Real numbers correspond directly to computational data types.
  • ✓ Beyond basic arithmetic, Exponentiation and Modulo (%) are core computational primitives essential for hashing, circular buffers, and scaling.
  • ✓ A Variable encapsulates changing or unknown parameters, whereas a Constant remains immutable across evaluations.
  • ✓ A Mathematical Expression is systematically constructed from Terms, Coefficients, Variables, and Constants.
  • ✓ Evaluating multi-operator expressions requires strict adherence to the PEMDAS / BODMAS precedence pipeline (Parentheses → Exponents → Mult/Div → Add/Sub).
  • ✓ Mathematical equality (=) denotes invariant propositional balance, distinct from programming variable assignment (=), which modifies physical memory state.