Objective Function — Definition, Formula, and Examples

#Algebra
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.
BT
Bhanzu TeamLast updated on July 20, 20267 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 = a_1x_1 + a_2x_2 + \dots + a_nx_n$, one coefficient per decision variable.

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 \ge 0$, $y \ge 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 \quad (\text{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 first instinct is to write the calorie content here, because that is the number the problem talks about most. But calories are the constraint, not the goal. $$Z = 5x + 8y \quad (\text{calorie content, wrong target})$$ That expression is the cost of nothing you were asked to optimise if you fill it with calories. The goal is cost, and cost per unit is 5 and 8. $$Z = 5x + 8y \quad (\text{cost, minimise})$$ The rescue is to read the sentence again: "at the lowest cost" names the objective; the calorie requirement is a constraint the diet must satisfy.

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) = 3(0) + 5(0) = 0$ $Z(4,0) = 3(4) + 5(0) = 12$ $Z(0,3) = 3(0) + 5(3) = 15$ $Z(2,2) = 3(2) + 5(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) = 10(5) + 12(0) = 50$ $Z(0,4) = 10(0) + 12(4) = 48$ $48 < 50$, so $(0,4)$ is 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.

Return from bonds is $0.06x$. Return from stocks is $0.09y$. $$Z = 0.06x + 0.09y \quad (\text{maximise})$$

Example 6

A bakery makes $x$ cakes (profit ₹120) and $y$ loaves (profit ₹40). At corners $(0,0)$, $(8,0)$, $(0,20)$, $(6,10)$, find the maximum profit.

$Z(0,0) = 120(0) + 40(0) = 0$ $Z(8,0) = 120(8) + 40(0) = 960$ $Z(0,20) = 120(0) + 40(20) = 800$ $Z(6,10) = 120(6) + 40(10) = 1120$ The maximum is at $(6,10)$. 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 (vertex) — 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 and reshaped wartime and industrial logistics. That is the destination: the same $Z = ax + by$ you write for a two-product shop is the seed of the models that route global supply chains.

The objective function never travels alone. The constraints fence off the allowed plans, and together they define the feasible region — the set of points the objective is optimised over. The full machinery lives in linear programming.

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. Ask "what single number does the problem want as big or as small as possible?" That first-instinct swap — optimising the calorie count instead of the cost — is the single most common setup error here.

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. The optimum can hide at a corner you skipped. The habit that fixes this is listing all corners first, then computing $Z$ for each on its own line.

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.

To take the objective function further with a teacher, work with a Bhanzu algebra tutor, get help with algebra, or explore math classes online. Want a live walkthrough? Book a free demo class.

Read More

Was this article helpful?

Your feedback helps us write better content

Frequently Asked Questions

Is the objective function always linear?
In linear programming, yes — it is a linear expression like $Z = ax + by$. 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: $Z = a_1x_1 + a_2x_2 + \dots + a_nx_n$.
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 — so you only evaluate $Z$ at the corners.
✍️ Written By
BT
Bhanzu Team
Content Creator and Editor
Bhanzu’s editorial team, known as Team Bhanzu, is made up of experienced educators, curriculum experts, content strategists, and fact-checkers dedicated to making math simple and engaging for learners worldwide. Every article and resource is carefully researched, thoughtfully structured, and rigorously reviewed to ensure accuracy, clarity, and real-world relevance. We understand that building strong math foundations can raise questions for students and parents alike. That’s why Team Bhanzu focuses on delivering practical insights, concept-driven explanations, and trustworthy guidance-empowering learners to develop confidence, speed, and a lifelong love for mathematics.
Related Articles
Book a FREE Demo ClassBook Now →