∇ProvenDecisions
Ctrl K

Consumer's best bundle (utility maximization): a convex optimization example, solved and checked

The consumer's best bundle (utility maximization) is a classic convex optimization problem. Here it is solved by a real solver (CLARABEL) and checked: every constraint, and the optimality certificate. Change the numbers below and solve your own.

Answer. You asked for: the optimal quantities of x and y to buy. The largest objective value is 2.65976, at x = 15.002, y = 13.9992. All 3 constraints are satisfied exactly. Optimal, numerically checked.

Solve your own version free, no account needed

The problem

A consumer with utility 0.3 ln x + 0.7 ln y has $100; good x costs $2 and good y costs $5. How much of each should she buy?

How the model was built

The objective as written from the problem, before the numbers are multiplied out:

The model

Each line has a plain-language note on the right.

make this as large as possible
limit 1: left side cannot exceed 100
quantity of good x purchased (units) cannot be negative
quantity of good y purchased (units) cannot be negative

What is being decided

There are 2 decision variables.

VariableTypeMeaning
xreal numberquantity of good x purchased (units)
yreal numberquantity of good y purchased (units)

Goal and limits

Maximize the objective subject to 3 constraints, of which 2 are simple bounds on a single variable.

Problem type

Conic (convex), complexity level 4: convex nonlinear functions such as log, exp, square roots or powers. Solved with CLARABEL at the Medium solver tier.

Picture

Shaded: every point that satisfies all the constraints. Dot: the optimum. Dashed: the objective's level line through it.

(15.002, 13.9992)-10-47.53251042.5176024xy

The answer at a glance

The optimal value of each decision, as the solver returned it.

x15.002y13.9992

Which constraints hold the answer in place

Binding (no slack left): (1) 2*x + 5*y <= 100. Changing a binding constraint changes the answer; a slack one can move a little without effect.

#ConstraintValueLimitSlackBinding
12*x + 5*y <= 1001001003.9533e-07yes
2x >= 015.002015.002
3y >= 013.9992013.9992

Algebraic model (low level)

Decision variables, objective and every constraint written out; this is exactly what the solver receives.

Model code (cvxpy)

The same model in cvxpy, ready to run.

import cvxpy as cp

x = cp.Variable(name='x')  # quantity of good x purchased (units)
y = cp.Variable(name='y')  # quantity of good y purchased (units)

objective = cp.Maximize(0.3*cp.log(x) + 0.7*cp.log(y))
constraints = [
    2*x + 5*y <= 100,
    x >= 0,
    y >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='CLARABEL')
print(problem.status, problem.value)
print('x =', x.value)
print('y =', y.value)

Solve your own

This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).

maximize 0.3*log(x) + 0.7*log(y)
subject to
2*x + 5*y <= 100
x, y >= 0
# x = quantity of good x purchased (units)
# y = quantity of good y purchased (units)
# asked: the optimal quantities of x and y to buy

Change the numbers and solve it

Checked: the app's answer matches the reference answer in our test set, which two solvers (CLARABEL, SCS) agree on. Built 2026-11-10.

Related examples

All 50 solved examples

Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.

What do you want to optimize?

Type the math, describe it in words, snap a photo or say it. ProvenDecisions builds the model, solves it, checks it and walks you through it.

One constraint per line, or separated by commas. Add integer: x, y or binary: z for whole-number decisions. LaTeX works too.

Try: