# Objective Function — Definition, Formula, and Examples

[Algebra](/content/tag/algebra/index.html)

TL;DR  
The objective function is the linear expression a linear programming problem sets out to maximize or minimize — usually written Z=ax+by, where x and y are decision variables. This article defines it, shows the Z=ax+by form, works six examples, and separates it clearly from the constraints.

Last updated on July 20, 2026 7 min read

The **objective function** is the linear expression that a linear programming problem is built to optimise — either maximised or minimised. It has the standard form Z=ax+by, where x and y are the **decision variables** (the quantities you control) and a and b are constant coefficients (the profit or cost per unit). Everything else in a linear programming problem exists to constrain this one function.

A **decision variable** is simply a quantity you get to choose — how many chairs to build, how many grams of a nutrient to include. The objective function turns those choices into a single score to push as high or as low as you can.

## Objective Function Formula  
For a two-variable linear programming problem, the objective function has the standard form: Z=ax+by. Each symbol has a fixed meaning:

| Symbol | Meaning |
| --- | --- |
| Z | The quantity being optimised (profit, cost, return) |
| x,y | Decision variables — the quantities you control |
| a,b | Constant coefficients — profit or cost per unit of x and y |

With more than two variables the form simply extends to Z=a1x1+a2x2+⋯+anxn.

## Components of a Linear Programming Problem  
The objective function is one of four parts that every linear programming problem carries. They fit together as follows:
- **Objective function** — the single linear quantity Z=ax+by to maximise or minimise.
- **Decision variables** — the unknowns (x, y) whose values you solve for.
- **Constraints** — the inequalities that limit the decision variables (available labour, material, budget).
- **Non-negativity restrictions** — the condition x≥0, y≥0, since most real quantities cannot be negative.

The objective function is the only part you optimise; the other three define *where* it is allowed to be optimised.

## How The Objective Function Is Optimised  
Because the objective function is linear and the feasible region is a convex polygon, its optimum always lands at a **corner point** (vertex) of that region. This is the corner-point theorem, and it turns an infinite search into a short checklist:
1. Graph the constraints and identify the feasible region.
2. Find the coordinates of every corner point of that region.
3. Evaluate Z=ax+by at each corner, one per line.
4. Pick the largest value for a maximisation problem, or the smallest for a minimisation problem.

You never have to test interior points — the winner is always a corner. Examples 3, 4, and 6 below apply exactly this method.

## Examples of the Objective Function  
### Example 1  
**Write the objective function for a shop that earns ₹40 profit per chair and ₹30 per table, where x = chairs and y = tables.**  
Profit per chair is 40, so chairs contribute 40x. Profit per table is 30, so tables contribute 30y. Total profit is the sum. Z=40x+30y(maximise)

### Example 2  
**A diet must supply energy at the lowest cost. Food A costs ₹5 per unit, food B costs ₹8 per unit. Write what to minimise.**  
The goal is cost, and cost per unit is 5 and 8. Z=5x+8y(cost, minimise)

### Example 3  
**Maximise Z=3x+5y at the corner points (0,0), (4,0), (0,3), and (2,2).**  
Evaluate Z at each corner, one per line:
- Z(0,0)=0
- Z(4,0)=12
- Z(0,3)=15
- Z(2,2)=16  
The largest value is at (2,2). Maximum Z=16.

### Example 4  
**A transport firm minimises cost Z=10x+12y. Which corner, (5,0) or (0,4), is cheaper?**  
- Z(5,0)=50
- Z(0,4)=48 (cheaper)  
Minimum cost is 48 at (0,4).

### Example 5  
**Set up the objective function for an investor putting x into bonds returning 6% and y into stocks returning 9%, maximising annual return.**  
Z=0.06x+0.09y(maximise)

### Example 6  
**A bakery makes x cakes (profit ₹120) and y loaves (profit ₹40).**  
Find the maximum profit at corners (0,0), (8,0), (0,20), (6,10):  
- Z(0,0)=0
- Z(8,0)=960
- Z(0,20)=800
- Z(6,10)=1120  
The maximum is at (6,10), so Maximum profit Z=1120.

## Why the Objective Function Sits at the Heart of Optimisation  
The objective function earns its central place because it turns a fuzzy goal into one measurable quantity.
- **It converts intent into arithmetic.** "Make the most profit" becomes Z=ax+by, a number you can compare across every allowed plan.
- **It works with the corner-point theorem.** For a linear objective over a convex feasible region, the optimum always sits at a corner — so you only test the corners, not every point.
- **It scales far beyond two variables.** Airlines optimise crew schedules and refineries blend fuels using objective functions with thousands of decision variables.

The idea traces to the simplex method that George Dantzig published in 1947, which made large objective functions solvable by machine.

## The Mistakes Students Make Most Often  
### Mistake 1: Confusing the objective function with a constraint  
**Where it slips in:** Reading a word problem and grabbing the first number-heavy sentence as the thing to optimise.
- **Don't do this:** Treat "at least 300 calories" as the objective when the question asks for the cheapest diet.
- **The correct way:** The objective is what you maximise or minimise (cost, profit, return); constraints are the inequalities you must satisfy.

### Mistake 2: Forgetting to test every corner point  
**Where it slips in:** Evaluating the objective at only one or two vertices and declaring an answer.
- **Don't do this:** Stop after checking (4,0) because it looks large.
- **The correct way:** Evaluate Z at every corner of the feasible region, then compare.

### Mistake 3: Dropping a coefficient  
**Where it slips in:** Writing Z=x+y when the per-unit values are 40 and 30.
- **Don't do this:** Ignore the coefficients because both variables "count."
- **The correct way:** Each decision variable carries its own coefficient: Z=40x+30y.

## Conclusion  
- The **objective function** is the one linear quantity a linear programming problem maximises or minimises, written Z=ax+by.
- Its coefficients are per-unit profit or cost; its variables are the decisions you control.
- It is optimised only over the feasible region, and its optimum lands at a corner point.
- The most common error is optimising a constraint by mistake, so name the target quantity first.

## Frequently Asked Questions  
Is the objective function always linear?  
In linear programming, yes. Nonlinear optimisation uses curved objective functions, but those fall outside linear programming.

Can an objective function have more than two variables?  
Yes. Real problems routinely use dozens or thousands.

What is the difference between the objective function and the constraints?  
The objective function is the single quantity you optimise; the constraints are the inequalities that limit which solutions are allowed.

Where is the optimum of the objective function found?  
At a corner (vertex) of the feasible region, by the corner-point theorem.
