liveBook · Manning

Mathematical variable

As explained in Classic Computer Science Problems in Swift: Essential techniques for practicing programmers

A mathematical variable is a symbol or quantity representing a value or attribute that can vary or be determined within a defined domain.

In a constraint-satisfaction problem (CSP), a variable is an entity whose value is selected from a domain. Domains list possible values; constraints restrict which combinations are acceptable. section 3.0

Two examples show how variables model a problem:

  • A meeting participant can be a variable; its domain is the hours when that person is available. section 3.0
  • An Australian region can be a variable with red, green, and blue as its domain; border constraints prevent adjacent regions from sharing a color. section 3.2
Figure 3.2. In a solution to the Australian map-coloring problem, no two adjacent parts of Australia can be colored with the same color.

The map illustrates the adjacency condition that constrains region variables. section 3.2

How Classic Computer Science Problems in Swift: Essential techniques for practicing programmers covers it

How deep it goes
Defines variables through CSP roles and examples, without developing a general mathematical theory of variables.
Examples
Uses meeting participants with availability times and Australian regions assigned red, green, or blue.
What you can do after
Apply the concept by representing participants or regions as variables and associating each with possible values.
How it connects
Ties variables to domains, constraints, assignments, and backtracking search in constraint-satisfaction problems.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Computer Science Problems in Swift: Essential techniques for practicing programmers. The section links point to the parts of the book it draws on.