Why Piecewise Optimization Needs Care
A model may change when a quantity crosses a threshold. A production process might have one capacity below a certain output and another above it; a fee might change after a usage limit; or a geometric constraint might have a different formula on different intervals. In each case, a single derivative calculation is not enough.
The reliable approach is to optimize each smooth case on its own interval, then compare all the candidates that could determine the overall maximum or minimum. Those candidates include not only interior critical points, but also domain endpoints and every breakpoint where the formula changes.
Piecewise Models and Feasible Choices
A piecewise function is defined by different formulas on different parts of its domain. For example, a model might use \(f_1(x)\) for \(a\le x\le c\) and \(f_2(x)\) for \(c\le x\le b\). The value at \(c\) must be specified consistently: if both formulas include \(c\), they must give the same value for the function to be well-defined.
Sometimes the objective itself is piecewise. In other situations, a constraint changes by interval, and the objective is still a single expression. If the constraint gives an upper bound on a quantity that increases the objective, the optimum may occur when that bound is met. Substituting the bound then produces a piecewise objective to analyze.
For each interval, keep its domain attached to its formula. A derivative equation may have solutions outside that interval; those solutions are not candidates for that case. After finding valid candidates, evaluate the original model at them—not at an expression extended beyond its stated interval.
A Candidate Principle for Continuous Piecewise Models
Suppose a function is continuous on a closed, bounded interval and is differentiable on the interior of each of finitely many smooth pieces. Then it has an absolute maximum and minimum. Any such optimum is either an overall endpoint, a breakpoint, or an interior point of a smooth piece where the derivative is zero.
The theorem combines two standard facts. Continuity on a closed, bounded interval guarantees that the absolute extrema are attained. At an interior extremum where the function is differentiable, Fermat’s theorem says the derivative is zero. A breakpoint is not necessarily differentiable, so it must be checked separately.
Why the Candidate Principle Works
Here is the reasoning in full. Let \(x^*\) be a point where a continuous piecewise-smooth function reaches an absolute maximum or minimum on a closed interval. Such a point exists by the extreme value theorem. If \(x^*\) is an overall endpoint or a breakpoint, it is already on the candidate list. Otherwise, it lies strictly inside one smooth piece.
Because \(x^*\) is inside that piece, there is a small interval around it on which the same differentiable formula applies. On this small interval, \(x^*\) is also a local maximum or minimum. Fermat’s theorem therefore gives \(f'(x^*)=0\). Thus every absolute extremum must appear among the listed candidates. Comparing the function values at all of them identifies the absolute extrema.
This reasoning depends on the stated conditions. If the model has a jump discontinuity, it may not attain its supremum or infimum, so the continuous-function theorem cannot be applied to the whole domain. In that situation, analyze each piece with its actual endpoint inclusions and also compare any relevant one-sided limits.
Mark the breakpoints and note whether each endpoint belongs to its interval.
If a constraint determines the best feasible value, substitute it into the objective first.
Differentiate each formula and keep only solutions inside that formula’s interval.
For a continuous model, evaluate the function there. For a jump or excluded endpoint, also consider the appropriate one-sided limit.
Choose the largest or smallest attained value as required, and check that its input satisfies the original model.
Worked Example: A Piecewise Height Constraint
Worked Example: Maximize Area Under a Changing Height Limit
A rectangle has width \(x\) and height \(y\), where \(0\le x\le 6\). Its height must satisfy \(0\le y\le g(x)\), with
Find the maximum possible area \(A=xy\).
For each fixed \(x\), area increases as \(y\) increases, because \(x\ge0\). Thus the greatest area at that width occurs at \(y=g(x)\). The breakpoint formulas agree: \(8-4=4\) and \(6-\frac12(4)=4\). The resulting area function is continuous at \(x=4\).
On the first interval, \(A_1'(x)=8-2x\). The equation \(8-2x=0\) gives \(x=4\), which is an endpoint of this case, not an interior point. For \(0\le x<4\), \(8-2x>0\), so \(A_1\) increases across the interval. Its endpoint values are \(A_1(0)=0\) and \(A_1(4)=32-16=16\).
On the second interval, \(A_2'(x)=6-x\). This derivative is positive for \(4\le x<6\) and zero at the endpoint \(x=6\), so the function increases to that endpoint. The case endpoint values are \(A_2(4)=24-8=16\) and \(A_2(6)=36-18=18\). Comparing the candidates gives a maximum area of \(18\) at \(x=6\). The corresponding height is \(g(6)=6-3=3\), so the rectangle has dimensions \(6\) by \(3\) and area \(6\cdot3=18\).
Check: \(x=6\) lies in the second case, and \(0\le3\le g(6)=3\). The point is feasible, and its area is \(18\), as claimed.
Worked Example: A Maximum at a Continuous Breakpoint
Worked Example: Compare a Corner with Interior Candidates
Find the absolute maximum of
At the breakpoint, the first formula gives \(10-(2-3)^2=9\), and the second gives \(9-0-0=9\). Thus the function is continuous at \(x=2\).
For the first case, \(f_1'(x)=-2(x-3)=6-2x\). Its only derivative zero is \(x=3\), which is outside \([0,2]\), so it is not a candidate for this case. Since \(6-2x>0\) throughout \([0,2]\), \(f_1\) increases there. Its largest case value is \(f_1(2)=9\); the other endpoint gives \(f_1(0)=10-9=1\).
For the second case, \(f_2'(x)=-2-2(x-2)=2-2x\). Its only derivative zero is \(x=1\), outside \([2,5]\). On this interval, \(2-2x<0\), so \(f_2\) decreases. Its largest case value is \(f_2(2)=9\); its other endpoint gives \(f_2(5)=9-6-9=-6\).
The maximum is \(9\), attained at the breakpoint \(x=2\). The derivative from the first formula at the breakpoint is \(6-4=2\), while the derivative from the second formula is \(2-4=-2\). The change from increasing to decreasing explains why the corner is a maximum even though neither formula has an interior critical point in its own interval.
Check: both formulas give \(f(2)=9\), and all other endpoint and case values found above are at most \(9\).
Worked Example: A Constraint with a Jump
Worked Example: Compare an Attained Maximum with a One-Sided Limit
A rectangle has \(0\le x\le6\) and \(0\le y\le g(x)\), where
Maximize its area \(A=xy\). As before, for each fixed \(x\), the greatest area occurs at \(y=g(x)\). On the first piece, \(A_1(x)=x(5-x)=5x-x^2\) for \(0\le x<3\). Its derivative is \(A_1'(x)=5-2x\), which is zero at \(x=\frac52\), a point in the interval. The values to compare are \(A_1(0)=0\), \(A_1(\frac52)=\frac{25}{2}-\frac{25}{4}=\frac{25}{4}\), and the left-hand limit as \(x\) approaches \(3\): \(15-9=6\). The limit value is not attained on this first piece because \(x=3\) is excluded.
On the second piece, \(A_2(x)=x\), for \(3\le x\le6\). It increases from \(A_2(3)=3\) to \(A_2(6)=6\). Comparing these results, \(\frac{25}{4}=6.25\) is larger than \(6\), so the absolute maximum area is \(\frac{25}{4}\), attained at \(x=\frac52\), \(y=5-\frac52=\frac52\).
Check: \(0\le\frac52<3\), and the height equals the allowed limit. The area is \(\frac52\cdot\frac52=\frac{25}{4}\). Although the constraint jumps at \(x=3\), the maximizing point is feasible and the maximum is attained.
Common Mistake: Stop at the First Critical Point
A critical point on one piece does not automatically give the maximum on that piece. For example, consider \(A_1(x)=x(8-x)=8x-x^2\) on \([0,4]\). A mistaken argument might test \(x=3\), calculate \(A_1(3)=3(8-3)=15\), and call it the maximum. But \(A_1'(3)=8-2(3)=2>0\), so the function is still increasing there. In fact, \(A_1(4)=4(8-4)=16>15\). The maximum on \([0,4]\) is at \(x=4\), not \(x=3\).
The correction is to check whether a proposed critical point actually solves the derivative equation and lies inside the case interval, then compare it with that case’s endpoints. In piecewise models, also check every breakpoint and return to the original constraints to verify feasibility.
What to Remember
Piecewise optimization is not a different derivative rule. It is careful application of the usual optimization process to each smooth case, followed by a complete comparison. Continuity lets you use the closed-interval candidate principle when its conditions hold. If a constraint or objective jumps, respect which endpoints are included and compare one-sided limits as well as attained values.
- Keep each formula paired with its correct interval.
- Reject derivative-zero solutions that lie outside that interval.
- Check the overall endpoints and every breakpoint, including corners.
- For discontinuous cases, distinguish an attained value from a one-sided limit.
- Verify the final point in the original model and compare its objective value with every relevant candidate.
Check Your Understanding
For each question, identify the relevant candidates and explain why they must be checked.
- Why must a breakpoint be checked even when the objective is continuous there?
- A derivative equation for one case gives a solution outside that case’s interval. Should it be included as a candidate for that case? Explain.
- What additional issue arises when a piece is open at a breakpoint and the objective has a finite one-sided limit there?
- For a rectangle with \(x\ge0\) and \(0\le y\le g(x)\), why does maximizing area at a fixed \(x\) lead to \(y=g(x)\), provided \(g(x)\ge0\)?
- State the conditions that allow the continuous piecewise candidate principle to guarantee an attained absolute maximum and minimum.