The polynomial $x^2 + x + 1$ is also a small program. Drawn as a tree, an addition at the root adds $x \times x$ to $x + 1$, and evaluating the tree from the leaves up returns the polynomial's value. Suppose we know only the function's values at 21 points between −1 and 1. An evolutionary algorithm can find the program itself, its structure as well as its constants, without being told what form the answer takes. In this unit's 30 seeded runs on those 21 points, 14 end with a program within 0.01 of the target at every point, and nine of the 14 programs are exactly $x^2 + x + 1$ (symbolic regression).
Genetic programming (GP) is the branch of evolutionary computation that searches for programs in this way. Its individuals are programs. Classically each is a tree whose internal nodes are functions, such as addition or a conditional, and whose leaves are inputs and constants. Fitness comes from running a program on test cases and comparing its outputs with the desired ones. Crossover swaps subtrees between two parents, and mutation replaces a subtree with a new random one, so the size and shape of a solution are searched over too.
The idea has early roots in Friedberg's experiments of the late 1950s and in Cramer's tree-based representation of 1985. John Koza's 1992 book turned it into a general method, with working programs for problems from curve fitting to control. One of the earliest and still most widely used applications is symbolic regression: searching for a formula rather than fitting the coefficients of a chosen one. The same freedom of form causes GP's best-known problem, bloat: programs tend to grow without improving.
The topic runs in three steps:
- the representation: what a program tree is, how the first trees are made, and how the operators change them;
- the application: symbolic regression worked through, and the growth without improvement that its runs display;
- the alternatives: linear, graph, grammar-based and stack-based programs in place of trees.
Two examples run through the unit. The quadratic $x^2 + x + 1$, the course's example after Poli, Langdon and McPhee (2008), is small enough to evaluate, cross and score by hand. Koza's quartic $x^4 + x^3 + x^2 + x$ is the classic test for complete runs, and 30 seeded runs of it recur from article to article.
Articles
Representing and varying programs
- Program trees in genetic programming: GP evolves program trees built from a function set and a terminal set, and a set of building blocks is usable when it has closure, so that every tree runs, and sufficiency, so that some tree solves the problem. Prefix notation and running a tree; function and terminal sets, closure, strongly typed GP and sufficiency. Fitness cases, how fast the number of trees grows with depth, and how GP differs from a genetic algorithm.
- Initialization and variation in genetic programming: how the first trees are created, and what one application of each operator does to a tree's size and shape. The full, grow and ramped half-and-half methods measured over 10,000 trees, with a formula for their mean size. Subtree crossover and Koza's 90/10 rule, four mutations, and the evidence on crossover versus mutation.
Applying it
- Symbolic regression: a conventional GP system fits the quadratic's 21 points in 14 of 30 runs and the quartic's 20 points in 10 of 30, and a formula that fits the data can be far from the target elsewhere. Fitness and hits, linear scaling, and constants. Thirty seeded runs on each example and the programs they evolve, then extrapolation, overfitting on noisy data, and modern benchmarks.
- Bloat in genetic programming: programs keep growing after growth stops paying. Under subtree crossover the mean size can rise only when selection picks larger programs more often than their share of the population, and limits or penalties on size hold the growth back. Introns, with 12 of the 27 nodes in one exact quartic solution doing nothing. The main explanations and the size evolution equation, and the methods of controlling size, four of them compared over 30 seeded runs of the quartic.
Other representations
- Genetic programming beyond trees: when a program is not a tree, a genotype is decoded into the program that runs, parts of the genotype are not expressed, and one mutation can change nothing or rewire the whole program. Linear GP, Cartesian GP, grammatical evolution and Push, each decoded by hand into the quadratic. What Koza's list of human-competitive results shows, and program search with language models.
Related topics
Genetic programming uses the selection schemes and population machinery of genetic algorithms with a different representation. Neuroevolution faces a similar problem of evolving structure as well as parameters, for neural networks rather than programs. Recent work combines program evolution with language models that propose the variations.
What comes next
The programs in this topic compute with arithmetic and logic. The next topic, neuroevolution, evolves neural networks instead: first their weights and, in time, their topology as well. It begins with fixed-topology neuroevolution.
References
- Koza, J. R. (1992). Genetic Programming: On the Programming of Computers by Means of Natural Selection. MIT Press. record · 6 pages
- Poli, R., Langdon, W. B., and McPhee, N. F. (2008). A Field Guide to Genetic Programming. Lulu.com. record · 5 pages
Reviewed: verified, 16 Nov 2026 · citations checked, 16 Nov 2026 · editorial review, 16 Nov 2026 · 3 revisions