Session 05 - Single Variable Optimisation

Mathematics for Master Students

Dr. Tobias Vlćek

Recap, Your Questions

Session 04 in a Nutshell

  • The derivative is the tangent’s slope: near \(p = 10\) a €1 rise adds about \(R'(10) = 800\) to the roastery’s revenue
  • Power, sum, product, quotient and chain rule differentiate every gallery function
  • \(e^x\) is its own derivative; \(\ln x\) has derivative \(\frac{1}{x}\)
  • \(f'' \geq 0\) convex, \(f'' \leq 0\) concave: the chord test as a sign check
  • Marginal cost \(C'(q) \approx\) cost of one more unit; where \(\tilde R'(q) = C'(q)\) hides the best output
  • Today: we turn a flat tangent into a recipe for the best decision

Common Issues in the Homework

  • The inner derivative went missing: with \(W(t) = 200e^{0.1t}\), the chain rule gives \(W'(t) = 20e^{0.1t}\): the factor \(0.1\) is not optional, so the answer is not \(200e^{0.1t}\)
  • Quotient order flipped: \(\left(\frac{\ln x}{x^2}\right)'\) needs \(f'g - fg'\), top’s derivative first; swapped gives \((2x\ln x - x)/x^4\), not \((x - 2x\ln x)/x^4\)
  • A rate read as a total: \(C'(100) = 35\) means the 101st unit costs about €35, not that 100 units do (that total is \(C(100) = 7500\))

Which tasks gave you trouble? Bring them up now. We take the time to go through them before we move on to today’s topic.

Warm-Up: Find the Flat Spot

Question

The roastery’s revenue is \(R(p) = 1200p - 20p^2\). Differentiate. At which price is the tangent horizontal?

  • Differentiate term by term: \(\;R'(p) = 1200 - 40p\)
  • Horizontal tangent means slope zero: \(\;1200 - 40p = 0 \;\Rightarrow\; p = 30\)
  • At \(p = 30\) revenue peaks at €18,000, the flat spot of Session 4's nudge plot
  • Revenue is not profit, though: today we find the roastery’s best price

Today’s Plan

Session 4 left the roastery’s question open: profit \(\pi(p) = -20p^2 + 1300p - 6200\) peaks at €32.50, but the roastery roasts at most 500 bags a week. Today: find where any smooth curve is flat, then check the boundaries.

  • Stationary points: where a profit hill is flat, \(\pi'(p) = 0\) for the roastery; marginal revenue = marginal cost for the print shop in \(q\)
  • The second-order condition: is a flat spot a peak or a valley?
  • Local vs global: is the peak the answer under a capacity cap?
  • Business optimisation: the print shop’s profit, then two U-shapes with no vertex formula

Stationary Points

Where Is the Top of the Hill?

Question

The roastery’s profit \(\pi(p) = -20p^2 + 1300p - 6200\) peaks at €32.50. What is the slope of the tangent there?

Zero: left of the top profit still rises with the price; right of it profit falls, and at the top the tangent is flat.

Profit hill over the price with three dashed tangents: rising at p = 25, flat at the top at p = 32.50, and falling at p = 40.

What Does “Optimal” Mean?

Optimisation means finding the input \(x\) that makes \(f(x)\) as large or as small as possible.

  • Local maximum at \(x^*\): \(f(x^*) \geq f(x)\) for all nearby \(x\), a peak, like €32.50 for the roastery
  • Local minimum at \(x^*\): \(f(x^*) \leq f(x)\) for all nearby \(x\), a valley
  • Global (absolute) extremum: the largest or smallest value on the whole domain
  • Business speaks this language daily: most profit, least cost, best order size

Setting the Slope to Zero

For the roastery, \(\pi'(p) = -40p + 1300 = 0 \Rightarrow p = 32.5\)

The same answer as Session 3's vertex formula \(-\frac{b}{2a} = \frac{1300}{40}\), but no parabola formula needed.

The First-Order Condition

This works for any smooth \(f\), parabola or not. A point \(x^*\) where the tangent is flat is a stationary point:

\[f'(x^*) = 0 \qquad \text{the first-order condition (FOC)}\]

  • It is necessary: every extremum of a smooth \(f\) away from the boundaries must be stationary
  • So the FOC hands us the candidates: solve \(f'(x) = 0\) to find them all

Where Can an Optimum Hide?

An extremum of a continuous function can only sit in one of three kinds of place:

  • A stationary point, where the tangent is flat (FOC)
  • A boundary of the domain, the edge of what is allowed
  • A kink, where \(f'\) does not exist (Session 4's non-differentiable points)

For the smooth business functions in this tutorial, the first two cover almost everything, and stationary points come first.

Finding the Candidates

Take \(f(x) = x^3 - 3x^2 - 9x + 5\). Where are its stationary points?

  • Differentiate: \(f'(x) = 3x^2 - 6x - 9\)
  • Factor: \(f'(x) = 3(x^2 - 2x - 3) = 3(x - 3)(x + 1)\)
  • Set to zero: \(3(x - 3)(x + 1) = 0 \;\Rightarrow\; x = -1 \ \text{ or } \ x = 3\)
  • Two candidates: \(x = -1\) and \(x = 3\), which peak, which a valley?
  • We will see soon!

Always factor \(f'(x)\) if you can: the stationary points are just its roots, and a factored form hands them to you directly.

Your Turn: Find Stationary Points

Question

Where are the stationary points of \(\;f(x) = x^3 - 12x\;\)?

\[f'(x) = 3x^2 - 12 = 3(x^2 - 4) = 3(x - 2)(x + 2) = 0\]

\[\Rightarrow \quad x = 2 \ \text{ or } \ x = -2\]

Common Mistake

Solving \(x^2 = 4\) as “\(x = 2\)” loses half the candidates. A square root has two signs; keep them both until the second-order condition sorts them.

Marginal Revenue = Marginal Cost

Session 4 promised: the best output is where marginal revenue meets marginal cost. Here is why.

Profit is revenue minus cost: \(\;\pi(q) = R(q) - C(q)\).

The first-order condition \(\pi'(q) = 0\) becomes:

\[\pi'(q) = R'(q) - C'(q) = 0 \quad \Longleftrightarrow \quad R'(q) = C'(q)\]

  • In words: keep producing while the next unit earns more than it costs
  • Stop where the extra revenue exactly equals the extra cost, \(R' = C'\)

Your Turn: Where Do They Meet?

Question

The roastery counted in bags (Session 4): \(\tilde R'(q) = 60 - \frac{q}{10}\), \(C'(q) = 5\). Profit maximal output?

\[60 - \frac{q}{10} = 5 \quad \Rightarrow \quad q = 550 \text{ bags}\]

Check: \(D(32.50) = 1200 - 650 = 550\), the FOC’s price seen in bags. But the roastery roasts at most 500 bags a week: keep that in mind.

2nd-Order Condition

Peak or Valley? Look at the Bend

Cubic curve with two flat points. At x = −1 the curve bends down and a dashed level chord lies below it; at x = 3 the curve bends up and the dashed level chord lies above it.

Question

Both tangents of \(f(x) = x^3 - 3x^2 - 9x + 5\) are flat. What tells the peak from the valley, without looking at the whole graph?

The chord at \(x = 3\) lies above: holds water, a valley.

At \(x = -1\) it lies below: spills water, a peak.

The Second Derivative Decides

Session 4's \(f''\) reads the bend as a sign. At a stationary point \(x^*\):

  • \(f''(x^*) > 0\): slope increases, falling then rising: a local minimum
  • \(f''(x^*) < 0\): slope decreases, rising then falling: a local maximum
  • \(f''(x^*) = 0\): the test is inconclusive, coming up

Back to \(f(x) = x^3 - 3x^2 - 9x + 5\): \(f''(x) = 6x - 6\)

\(x^*\) \(f''(x^*)\) verdict \(f(x^*)\)
\(-1\) \(-12 < 0\) maximum \(10\)
\(3\) \(12 > 0\) minimum \(-22\)

The Recipe in Four Steps

What we just did for the cubic, as a recipe for every interior candidate:

  1. Differentiate: compute \(f'(x)\)
  2. Solve \(f'(x) = 0\): the stationary points are the candidates (FOC)
  3. Differentiate again and evaluate \(f''\) at each candidate
  4. Classify: \(f'' > 0\) minimum, \(f'' < 0\) maximum, \(f'' = 0\) undecided (SOC)

Your Turn: Classify the Candidates

Question

Back to \(f(x) = x^3 - 12x\) with stationary points \(x = 2\) and \(x = -2\). Which is which?

(a) Maximum at \(2\), minimum at \(-2\) (b) Minimum at \(2\), maximum at \(-2\)
(c) Both are minima (d) The test is inconclusive

(b), with \(f''(x) = 6x\):

\(x^*\) \(f''(x^*)\) verdict \(f(x^*)\)
\(2\) \(12 > 0\) minimum \(8 - 24 = -16\)
\(-2\) \(-12 < 0\) maximum \(-8 + 24 = 16\)

When \(f''\) Is Silent

Both have \(f'(0) = 0\) and \(f''(0) = 0\). Yet \(x^3\) keeps rising (a saddle point), while \(x^4\) has a minimum.

Two panels, x³ and x⁴, each with a dashed horizontal tangent at the origin. x³ keeps rising through its flat point, a saddle; x⁴ touches the tangent from above, a minimum.
  • \(f'' = 0\) says nothing: read \(f'\) instead — \(+ \to -\) a maximum, \(- \to +\) a minimum, same sign on both sides: neither
  • This sign check is the first-derivative test (cheatsheet); in practice the SOC settles almost every case

Your Turn: Is €32.50 a Peak?

Question

The FOC put the roastery’s candidate at €32.50, with \(\pi'(p) = -40p + 1300\). Differentiate once more: what is €32.50?

(a) A local maximum, \(\pi'' = 40\) (b) A local minimum, \(\pi'' = -40\)
(c) A local maximum, \(\pi'' = -40\) (d) Undecided, \(\pi'' = 0\)

(c): \(\pi''(p) = -40 < 0\): concave, it spills water, a peak.

Local vs Global

Is €32.50 the Roastery’s Price?

Question

The roastery’s profit \(\pi(p) = -20p^2 + 1300p - 6200\) peaks at €32.50. The roastery roasts at most 500 bags a week. Should the roastery charge €32.50?

Capacity Caps the Price

  • At €32.50 demand is \(D(32.5) = 550\) bags, over capacity
  • Capacity caps bags from above: \(\;D(p) \leq 500 \;\Leftrightarrow\; 1200 - 20p \leq 500 \;\Leftrightarrow\; 700 \leq 20p \;\Leftrightarrow\; p \geq 35\)
  • In words: a higher price sells fewer bags, so the roastery must charge at least €35
  • At €60 demand is zero, so the allowed prices are \([35, 60]\)

The Boundary Wins

Profit parabola for prices from 20 to 60. Prices below 35 are shaded as needing over 500 bags, and the peak at €32.50 lies inside that shaded band. The best allowed point sits at p = 35, the left edge of the allowed prices, from where profit only falls.
  • On \([35, 60]\), \(\pi'(p) = -40p + 1300 < 0\): profit only falls, so the boundary \(p = 35\) wins
  • €14,800 a week, €125 below the peak the roastery cannot reach

Your Turn: Does the Limit Bind?

Question

Counted in bags, the roastery’s profit is concave with its peak at \(q = 550\). What is the best output if it can roast at most 450 bags? And with a bigger roaster, at most 600? Shout both numbers.

  • Capacity 450: the peak lies outside; profit still rises up to \(450\), so the boundary \(q = 450\) wins
  • Capacity 600: the peak \(q = 550\) lies inside, so the stationary point wins, and the edge is irrelevant
  • The boundary wins only when the constraint binds: check where the peak lies first

Local Is Not Global

A local optimum is best only in its neighbourhood:

  • The cubic’s valley at \((3, -22)\): yet \(f(x) \to -\infty\) as \(x \to -\infty\)
  • Its peak at \((-1, 10)\): yet \(f(x) \to +\infty\) as \(x \to +\infty\)
  • On all of \(\mathbb{R}\) neither is global: this \(f\) has no global optimum at all

A Floor Is Not a Minimum

Question

The roastery’s average cost \(A(q) = 200/q + 5\) never drops below €5. What is the lowest average cost the roastery can actually reach?

  • €7 at 100 bags, €5.40 at 500, €5.20 at 1000: every \(q\) is beaten by a bigger one, so on \((0, \infty)\) there is no minimum, only a floor
  • With capacity it sells 1 to 500 bags, the closed interval \([1, 500]\): the lowest value sits at the boundary \(q = 500\), €5.40
  • Extreme Value Theorem: a continuous \(f\) on a closed interval \([a, b]\) always reaches a global max and a global min; on \((0, \infty)\) nothing is guaranteed

The Closed-Interval Recipe

The roastery’s €35 was this recipe: no stationary point inside \([35, 60]\), so an endpoint won. In general, compare a short list:

  1. Find every stationary point in \((a, b)\): solve \(f'(x) = 0\)
  2. Evaluate \(f\) at each of them
  3. Evaluate \(f\) at both endpoints, \(f(a)\) and \(f(b)\)
  4. The largest value is the global max; the smallest is the global min

Common Mistake

Finding stationary points but forgetting the endpoints. The global optimum often sits at a boundary: skip it and you get the wrong answer.

Comparing the Candidates

On all of \(\mathbb{R}\), \(f(x) = x^3 - 3x^2 - 9x + 5\) has no global optimum; on \([0, 5]\) the Extreme Value Theorem guarantees a global max and min. Of its stationary points \(-1\) and \(3\), only \(3\) lies inside:

candidate \(f(x)\)
\(x = 0\) (endpoint) \(5\)
\(x = 3\) (stationary) \(-22\)
\(x = 5\) (endpoint) \(10\)

Largest value \(10\): the global max sits at the boundary \(x = 5\). Smallest value \(-22\): the global min is the stationary point \(x = 3\).

Your Turn: Global on an Interval

Question

Find the global maximum of \(f(x) = x^2 - 4x\) on \([0, 5]\). Shout the maximum value.

\(f'(x) = 2x - 4 = 0\) gives the stationary point \(x = 2\):

candidate \(f(x)\)
\(x = 0\) (endpoint) \(0\)
\(x = 2\) (stationary) \(4 - 8 = -4\)
\(x = 5\) (endpoint) \(25 - 20 = 5\)

The global max is \(5\) at the endpoint \(x = 5\); the stationary point is the global minimum.

Business Optimisation

Where Is the Gap Widest?

The roastery’s next bag always costs €5. Session 4's print shop is different: its next unit gets dearer. From here on \(C\), \(R\) and \(\pi\) are the print shop’s: \(C(q) = 0.5q^2 + 10q + 200\), and to sell more it must cut the price to \(100 - 0.5q\), so \(R(q) = 100q - 0.5q^2\).

Revenue curve, bending downward, and cost curve, bending upward, of the print shop for quantities from 0 to 90. Revenue lies above cost over almost the whole range, and the vertical gap between them, the profit, first widens and then narrows again.

Profit = vertical gap between the curves. Guess the \(q\) where it is widest.

Build the Profit Function

Subtract cost from revenue, term by term:

\[\pi(q) = (100q - 0.5q^2) - (0.5q^2 + 10q + 200)\]

\[\pi(q) = -q^2 + 90q - 200\]

  • A downward parabola, like the roastery’s profit hill
  • Differentiate: \(\;\pi'(q) = -2q + 90\)
  • The fixed cost \(200\) vanishes under differentiation: it shifts profit, not the optimum

Solve and Verify

Revenue and cost curves of the print shop over the quantity. A dashed vertical segment at q = 45 marks the widest gap between them, the point where both curves are equally steep.
  • FOC: \(\pi'(q) = -2q + 90 = 0 \;\Rightarrow\; q = 45\), and \(R'(45) = 55 = C'(45)\), marginal revenue = marginal cost
  • SOC: \(\pi''(q) = -2 < 0\) → concave → a maximum, confirmed
  • Value: \(\pi(45) = -2025 + 4050 - 200 = 1825\), a maximum profit of €1825

Your Turn: Fixed Costs Rise

Question

The rent goes up: fixed costs rise from \(200\) to \(500\), so \(C(q) = 0.5q^2 + 10q + 500\). What happens to the optimal output \(q = 45\) and to the maximum profit?

(a) \(q\) falls, profit falls (b) \(q\) rises, profit falls
(c) \(q\) unchanged, profit falls by \(300\) (d) \(q\) unchanged, profit unchanged

(c): \(\pi(q) = -q^2 + 90q - 500\) has the same derivative \(\pi'(q) = -2q + 90\), so the FOC still gives \(q = 45\); the constant only shifts the curve down.

Fixed costs never change the decision, only the result. That is the practical meaning of “constants differentiate to zero”.

Your Turn: A Better Price

Question

Demand improves and revenue becomes \(R(q) = 120q - 0.5q^2\), cost stays \(C(q) = 0.5q^2 + 10q + 200\). What is the new optimal output? Shout the number.

  • Profit: \(\pi(q) = 120q - 0.5q^2 - 0.5q^2 - 10q - 200 = -q^2 + 110q - 200\)
  • FOC: \(\pi'(q) = -2q + 110 = 0 \Rightarrow q = 55\)
  • SOC: \(\pi''(q) = -2 < 0\), a maximum; and \(R'(55) = 65 = C'(55)\) ✓

Is There a Best Volume?

The roastery’s average cost only falls towards €5: a floor, not a minimum. The print shop’s differs:

\[A(q) = \frac{C(q)}{q} = \frac{200}{q} + 10 + 0.5q\]

  • \(200/q\): the fixed €200 spread over more units pulls it down
  • \(0.5q\): each further unit costs more, which pulls it up

U-shaped average cost curve of the print shop over the quantity: it falls steeply for small quantities, reaches its lowest point at around 20 units, and rises slowly afterwards.

Guess the \(q\) at the bottom.

Solve and Verify: Cost Minimum

\[A(q) = C(q)/q = 200/q + 10 + 0.5q\]

  • FOC: \(A'(q) = -200/q^2 + 0.5 = 0 \;\Rightarrow\; q^2 = 400 \;\Rightarrow\; q = 20\), the only positive root
  • SOC: \(A''(q) = 400/q^3 > 0\) for \(q > 0\): convex, a minimum
  • Value: \(A(20) = 10 + 10 + 10 = 30\): the falling part \(200/20\) and the rising part \(0.5 \cdot 20\) are equal, both €10

Notice the shape \(\frac{a}{q} + bq\): a falling term against a rising one. Next, the most famous formula in inventory management shares it.

How Much to Order?

The warehouse sells \(1000\) units a year. Every order costs €80 (truck, paperwork). Every unit on the shelf costs €4 a year. Order all at once, or a little every week?

Sawtooth curve of the stock over one year: at each of five deliveries the stock jumps to q and then drains in a straight line to zero. A dashed horizontal line marks the average stock q/2.

Order \(q\) units at a time: stock jumps to \(q\) at each delivery, then drains to zero before the next one arrives.

Your Turn: Bigger Batches

Question

You switch to larger orders \(q\), same annual demand. What happens to the yearly ordering cost and the yearly holding cost?

(a) Ordering cost rises, holding cost falls (b) Ordering cost falls, holding cost rises
(c) Both fall (d) Both rise

(b): fewer orders per year, so fewer €80 bills; but a higher average stock \(q/2\), so more €4 shelf costs.

This makes the total cost U-shaped, and a U has a bottom to find.

Ordering Cost Plus Holding Cost

We want the order size \(q\) that minimises total cost, the economic order quantity (EOQ).

  • Ordering: \(\frac{1000}{q}\) orders a year, €80 each: \(\;\frac{1000}{q}\cdot 80 = \frac{80000}{q}\)
  • Holding: on average \(\frac{q}{2}\) units in stock, €4 each: \(\;\frac{q}{2}\cdot 4 = 2q\)
  • Total cost: \(T(q) = \frac{80000}{q} + 2q\)
  • The U in numbers: \(T(100) = T(400) = 1000\), but \(T(200) = 800\): the U dips in between

The EOQ: First-Order Condition

The two dashed cost curves cross exactly under the bottom of the total.

The dashed ordering cost 80000/q falls, the dashed holding cost 2q rises, and their sum, the total cost, is U-shaped. The two dashed curves cross at q = 200, exactly under the minimum of the total cost at 800.

The EOQ: Verify and Read

  • FOC: \(T'(q) = -80000/q^2 + 2 = 0\) \(\;\Rightarrow\; q^2 = 40000 \;\Rightarrow\; q = \pm 200\); only \(q^* = 200\) is a quantity
  • SOC: \(T''(q) = 160000/q^3 > 0\) for all \(q > 0\) → convex → a minimum
  • At \(q^* = 200\): ordering cost \(= 400\) and holding cost \(= 400\), equal, total €800

The Square-Root Formula

Replace \(1000\), \(80\) and \(4\) by any demand \(D\), order cost \(K\) and holding cost \(h\) (\(K\) is the cost per order, not capital), so \(T(q) = DK/q + hq/2\). The FOC \(T'(q) = -DK/q^2 + h/2 = 0\) solves in symbols:

\[q^2 = 2DK/h \;\Rightarrow\; \boxed{\,q^* = \sqrt{2DK/h}\,}\]

  • Check: \(\sqrt{2 \cdot 1000 \cdot 80 / 4} = \sqrt{40000} = 200\) ✓
  • The FOC is the balance: multiply it by \(q\) and ordering cost \(DK/q\) equals holding cost \(hq/2\)

Your Turn: Compute the EOQ

Question

Annual demand \(D = 1800\) units, \(K = 25\) per order, holding cost \(h = 4\) per unit and year. What is the economic order quantity? Shout the number.

\[q^* = \sqrt{\frac{2 \cdot 1800 \cdot 25}{4}} = \sqrt{\frac{90000}{4}} = \sqrt{22500} = 150\]

  • Balance: ordering \(\frac{1800}{150} \cdot 25 = 300\), holding \(\frac{150}{2} \cdot 4 = 300\) ✓
  • Rhythm: \(\frac{1800}{150} = 12\) orders a year, one a month

Your Turn: Ordering Cost Doubles

Question

A supplier doubles the fixed cost \(K\) per order. According to \(q^* = \sqrt{\frac{2DK}{h}}\), does the economic order quantity rise or fall, and by how much?

  • \(q^*\) grows with \(K\) under the root, so a larger \(K\) makes \(q^*\) rise
  • Doubling \(K\) multiplies \(q^*\) by \(\sqrt{2} \approx 1.41\), about a 41% larger order
  • Intuition: if each order costs more, you order less often in bigger batches

Closing

Key Takeaways

  • FOC: the roastery’s profit hill is flat where \(\pi'(p) = -40p + 1300 = 0\): €32.50, found without the vertex formula
  • SOC: \(\pi'' = -40 < 0\) makes it a peak; a flat tangent alone can be a saddle (\(x^3\) at \(0\)), and \(f'' = 0\) says nothing (\(x^4\))
  • Boundaries: €32.50 needs 550 bags: capacity allows 500, so \(p \geq 35\); profit falls on \([35, 60]\) and the boundary wins, €35

The Two Business Rules

  • MR = MC: the print shop stops at \(q = 45\), where the next unit earns €55 and costs €55
  • Balance: the print shop’s average cost bottoms out at €30 (\(q = 20\)); the warehouse orders \(200\) at a time: falling and rising costs equal, \(q^* = \sqrt{2DK/h}\)

That’s it for today.

Any Questions?

Until the Next Session

  • Work through the Tasks: optimisation drills with worked solutions
  • Check yourself with the Self-Test quiz
  • Keep the Cheatsheet next to you, the FOC/SOC recipe lives on it
  • Note down anything unclear, we start next session with your questions

The recipe is always the same: differentiate, set \(f' = 0\) and solve, let \(f''\) decide, then compare with the endpoints. Name the goal (maximise or minimise) and the sign of \(f''\) you want follows.

Preview: Session 6: Linear Systems

  • Today every decision had one unknown: one price, one output, one order size
  • Next time the roastery blends two beans into one bag: two unknowns, two conditions, both must hold
  • Elimination and substitution, done systematically
  • Gaussian elimination for bigger systems, market equilibrium, production planning

See you there, and bring your questions!

Literature & Further Reading

  • These sessions cover the essentials: textbooks offer more depth and practice
  • Start with Sydsæter et al. (2012) or Jacques (2015); full recommendations on the tutorial’s literature page
Jacques, Ian. 2015. Mathematics for Economics and Business. 8th ed. Always Learning. Pearson.
Sydsæter, Knut, Peter J. Hammond, and Arne Strøm. 2012. Essential Mathematics for Economic Analysis. 4th ed. Pearson.