Extend to all-units price breaks
Under an all-units discount schedule, unit cost C_k depends on the tier k. The total cost function gains a D*C_k purchase term that varies by tier - so the tier matters and the term doesn’t drop out. Also, holding cost is H_k = i*C_k, so H itself shifts step-wise downward as the tier improves[1].
Why you can’t just set the derivative to zero. The total cost function is piecewise: TC_k(Q) for each tier k, valid on the tier’s feasible quantity range. The function is discontinuous at break points (drop in C_k drops D*C_k discontinuously). Differentiating within a tier gives the Wilson-style Q*_k = sqrt(2DS/H_k); that candidate is valid only if it falls inside the tier’s quantity range. If not, the tier’s candidate is its lower break point (the minimum feasible Q in that tier).
The stepwise tier algorithm.
- For each tier k, compute Q*_k = sqrt(2DS/(i*C_k)).
- If Q*_k is within the tier’s quantity range, that’s the candidate Q.
- Otherwise the candidate Q is the tier’s lower break point (forced jump).
- Evaluate TC_k(Q_candidate) = (D/Q_candidate)*S + (Q_candidate/2)*H_k + D*C_k.
- The lowest TC across all tiers wins; that Q is the optimal order quantity.
The quantity discount calculatorruns this algorithm with user-supplied tiers and shows the candidate Q and total cost for each, so the buyer can see which tier wins and by how much[2]. Incremental discounts (where the lower price applies only to units above the break) follow a similar but smoother derivation; the function is continuous and a single-stationary-point search works.