← Learn AI
C_000128 · mathematical foundations · advanced

Duality Primal and Dual

Every optimisation problem has a dual whose optimum bounds the original.

Step 1 of 4

In words

What it is, why it matters, and what it is like.

Why am I learning this?

Imagine you are planning a road trip with a strict budget and a set of destinations you must visit. You want the fastest route, but you cannot spend more than $500 on gas and hotels. Solving this directly can be messy because every choice affects your remaining budget in complex ways. Duality gives you a different way to look at the same trip. Instead of trying to find the best route first, you assign a 'price' to every rule—like how much extra time it would cost to add one more stop to your list or how much your travel time would improve if your budget were $10 larger. These prices tell you the value of each constraint. Often, calculating these values is much easier than finding the exact route. Once you have these 'shadow prices,' they act as a reliable lower bound for the true cost. If the price of relaxing your constraints matches the cheapest possible trip, you know you have found the perfect solution. This technique is why systems that recommend flights, allocate factory resources, or train artificial intelligence models can find answers quickly and accurately.

The idea, in plain terms

Imagine you are trying to book a flight from Delhi to Mumbai for business. You need to get there by Friday afternoon. Your goal is to find the cheapest ticket price possible, but there is a rule: the total weight of your luggage, including checked bags, must be at least 20 kg because you have heavy prototypes to deliver.

You look at several options. Airline A charges ₹4,000 but only allows 15 kg (too light). Airline B charges ₹6,000 and allows 30 kg (valid, but expensive). You search through the database and find the best valid option: a ticket for exactly 20 kg of luggage at a price of ₹4,200. This ₹4,200 is your minimum cost under the rule.

Now, let's look at this from the perspective of the rule itself. Ask yourself this question: How much more would you be willing to pay for one extra kilogram of baggage allowance? If you could carry 21 kg instead of 20, would you pay ₹50 more? Or ₹200 more? Let's say the answer is ₹100. This means the 'value' of that extra kilogram to your specific situation is ₹100. In optimization terms, this value is called the shadow price of the baggage constraint.

Here is the key insight: The shadow price (₹100) tells you how much the total cost would change if the rule changed slightly. But more importantly, it provides a check on your work. The original problem—finding the cheapest flight with at least 20 kg—is called the primal problem. The second question—calculating the value of relaxing that constraint—is called the dual problem.

The principle of weak duality states that the value derived from the dual perspective will never overestimate the true cost. In our example, if you calculated a shadow price that suggested your trip should only cost ₹3,000, you would know something is wrong, because you already found a valid ticket for ₹4,200. The dual provides a lower bound; it sets a floor.

In many cases, particularly when the problem is 'well-behaved' (a property known as convexity), the two numbers meet exactly. This is strong duality. It means the minimum cost of the trip (₹4,200) is mathematically equal to the maximum value you place on relaxing the constraint. When this happens, solving the dual problem gives you the exact answer to the primal problem, often with far less computational effort.

An analogy

Think of a city council deciding how to allocate a limited water supply among three districts during a drought. The council wants to minimize the total economic loss caused by water rationing, subject to the rule that the total water distributed must equal exactly 100 million gallons.

The primal problem asks: 'How much water should District A, B, and C get to minimize total loss?' This is hard to answer directly because you don't know how much each district values the water.

The dual problem flips the perspective. It asks: 'What price per gallon for water would cause each district to voluntarily request exactly their fair share, summing to 100 million gallons?' The council sets a price (the dual variable). If the price is too low, districts hoard water (demand exceeds supply). If the price is too high, they conserve too much (supply exceeds demand). The optimal dual solution is the exact price that balances supply and demand.

The analogy holds because finding the right price (dual) often requires fewer calculations than figuring out each district's specific needs (primal). When the market clears at the right price, the total loss in the primal view equals the revenue in the dual view. This equality is strong duality. The caveat is that real-world districts might have complex, non-linear pain curves for water shortages, whereas simple mathematical models assume straight-line relationships; however, the core logic of pricing constraints remains valid.

Definition

For every optimization problem seeking to minimize cost under constraints (the primal), there exists a corresponding problem that maximizes the value of relaxing those constraints (the dual). The optimal value of the dual always provides a lower bound on the optimal value of the primal, and under specific conditions known as strong duality, the two values are equal.

Where this sits

This concept sits directly beside Linear Programming, which is the study of optimizing linear objectives subject to linear constraints, where every problem has a corresponding dual. It also connects closely with Lagrange Multipliers, which are the mathematical tools used to calculate the dual variables (shadow prices) by incorporating constraints into the objective function.

Signal from the Frontier

Get the next essay on mind, machine, and meaning

Essays at the intersection of AI, philosophy, and Indian governance. No promotional content.

We'll send a one-click sign-in link to confirm. No password needed.

Views expressed are personal and do not represent the Government of India or the Government of Uttarakhand.

Duality Primal and Dual — Learn AI — Dr. B.V.R.C. Purushottam