Tutorials › Calculus I › Why Integer Choices Need A Final Comparison

Optimization and Newton's Method · Tutorial 881 of 1495

Why Integer Choices Need A Final Comparison

Learn how to use a continuous optimum to narrow an integer optimization problem, then compare feasible choices to identify the discrete optimum.

Advanced 9 min read

What You'll Learn

  • Explain why a continuous critical point may not be a feasible integer decision.
  • Identify the neighboring feasible integers around a strict continuous maximum or minimum.
  • Prove when those neighboring integers contain the discrete optimum.
  • Include feasible boundary values when the continuous optimum lies outside the decision interval.
  • Recognize why rounding alone is not a reliable optimization method.
  • Compare objective values to verify the final integer choice.

Why a Continuous Optimum Is Not the Final Answer

A continuous optimization problem allows the decision variable to take every real value in a specified interval. A discrete decision may instead be restricted to integers: a number of workers, machines, batches, or items cannot be fractional. In that setting, a point that optimizes the continuous model might not be an allowed decision.

Calculus can still help. If the objective has a single peak or trough, its continuous optimum can identify nearby integer candidates. But those candidates must be feasible, and their objective values must be compared. If the continuous optimum is outside the feasible interval, or the objective has a different shape, a boundary value or other feasible integer may matter instead.

Key takeaway: A continuous optimum can help locate a discrete optimum, but it is not itself the final answer unless it is an allowed decision. The discrete choice must be feasible and must win a comparison of objective values.

Integer Feasibility and Finite Comparisons

Suppose a decision \(x\) must be an integer in the closed interval \([a,b]\), where \(a\le b\). The feasible integer set is \([a,b]\cap\mathbb{Z}\). It is finite, but it may be empty. If it is nonempty, an objective \(f\) has a maximum and a minimum on that set: there are only finitely many feasible values to compare.

Definition: A discrete maximum of \(f\) over a feasible integer set \(S\) is a value \(f(k)\) that is at least as large as \(f(j)\) for every \(j\in S\). A discrete minimum is defined by reversing the inequality. The maximizing or minimizing decision is the integer \(k\) at which that value is attained.

This finite-set fact is useful, but it does not say which integers to compare. If there are only a few feasible choices, checking every one is direct. When the set is large, the shape of the continuous objective may narrow the comparison to a small number of candidates.

A Peak Between Two Integers

Consider a function with a strict continuous maximum at \(c\): it increases as \(x\) approaches \(c\) from the left and decreases as \(x\) moves right from \(c\). If \(c\) is not an integer, the natural candidates are the integers immediately on either side, \(\lfloor c\rfloor\) and \(\lceil c\rceil\), provided they are feasible. The floor is the greatest integer no greater than \(c\), and the ceiling is the least integer no less than \(c\).

Worked Example: Comparing Integers Near a Continuous Maximum

Maximize \(f(x)=-x^2+\frac{32}{5}x\) over integer decisions \(x\in[0,8]\). First locate the continuous maximum by differentiating:

$$ f'(x)=-2x+\frac{32}{5}. $$

Setting the derivative equal to zero gives \(-2x+\frac{32}{5}=0\), so \(x=\frac{16}{5}=3.2\). The derivative is positive for \(x<\frac{16}{5}\) and negative for \(x>\frac{16}{5}\), so this is a strict continuous maximum. The neighboring integers \(3\) and \(4\) are both feasible. Evaluate the objective at each:

$$ f(3)=-9+\frac{96}{5}=\frac{51}{5}, \qquad f(4)=-16+\frac{128}{5}=\frac{48}{5}. $$

Since \(\frac{51}{5}>\frac{48}{5}\), the best of these candidates is \(x=3\). The derivative signs show that every feasible integer below \(3\) has a lower value than \(f(3)\), and every feasible integer above \(4\) has a lower value than \(f(4)\). Thus \(x=3\) is the discrete maximum. As a check, substituting \(x=3\) into the original objective gives \(-3^2+\frac{32}{5}(3)=-9+\frac{96}{5}=\frac{51}{5}\), as calculated.

The continuous optimum narrowed the search to two integers, but the comparison determined which one won. The two values need not be equal, and knowing which integer is closer to \(c\) is not, by itself, a substitute for comparing objective values.

Why the Neighboring-Integer Rule Works

Here is a precise version of the rule for maximization. The nonempty-feasible-set condition matters: an interval can contain a continuous maximum but contain no feasible integer at all.

Theorem: Let \(f\) be continuous on \([a,b]\) and differentiable on \((a,b)\). Suppose \([a,b]\cap\mathbb{Z}\ne\varnothing\), and suppose there is a \(c\in(a,b)\) such that \(f'(x)>0\) for every \(x\in(a,c)\) and \(f'(x)<0\) for every \(x\in(c,b)\). Then a maximum of \(f\) over the feasible integers is attained at one of the feasible integers among \(\lfloor c\rfloor\) and \(\lceil c\rceil\).

The derivative signs imply that \(f\) increases to \(c\) and decreases after \(c\). To justify this, take any \(u<v\) in \([a,c]\). The Mean Value Theorem applies on \([u,v]\), since \(f\) is continuous there and differentiable between \(u\) and \(v\). It gives a point \(d\in(u,v)\) such that \(f(v)-f(u)=f'(d)(v-u)>0\). Thus \(f(v)>f(u)\). The same theorem applied to \(c\le u<v\le b\) gives \(f(v)-f(u)=f'(d)(v-u)<0\), so \(f(v)<f(u)\). In particular, \(f\) increases up to \(c\) and decreases after \(c\).

1
Consider feasible integers to the left.
If \(c\) is not an integer and there is a feasible integer less than \(c\), the greatest such integer is \(\lfloor c\rfloor\); if \(c\) is an integer, step 3 handles it. It lies in \([a,b]\): it is at least as large as any feasible integer on the left, and it is less than \(c<b\). Since \(f\) increases to \(c\), no feasible integer further left has a greater value.
2
Consider feasible integers to the right.
If \(c\) is not an integer and there is a feasible integer greater than \(c\), the least such integer is \(\lceil c\rceil\); if \(c\) is an integer, step 3 handles it. It lies in \([a,b]\), and since \(f\) decreases after \(c\), no feasible integer further right has a greater value.
3
Include an integer peak if there is one.
If \(c\) is an integer, it is feasible because \(c\in(a,b)\), and \(f\) increases before it and decreases after it. It is therefore a maximizing integer. In all cases, the feasible integers among the floor and ceiling contain a maximum.

The proof also explains why nonempty feasibility is needed: there must be at least one integer decision for a discrete maximum to be attained. For a minimum, the corresponding rule applies when the derivative is negative before \(c\) and positive after it. The function then decreases to \(c\) and increases after it, so the neighboring feasible integers contain a minimum.

Worked Example: A Continuous Minimum Between Integers

Worked Example: Choosing the Better Integer for a Minimum

Minimize \(g(x)=(x-\frac{13}{5})^2+2\) over integers \(x\in[0,6]\). Differentiating gives:

$$ g'(x)=2\left(x-\frac{13}{5}\right). $$

The derivative is negative when \(x<\frac{13}{5}\) and positive when \(x>\frac{13}{5}\), so \(c=\frac{13}{5}=2.6\) is a continuous minimum. The neighboring feasible integers are \(2\) and \(3\). Substituting each into the objective gives:

$$ g(2)=\left(2-\frac{13}{5}\right)^2+2 =\frac{9}{25}+2 =\frac{59}{25}, $$ $$ g(3)=\left(3-\frac{13}{5}\right)^2+2 =\frac{4}{25}+2 =\frac{54}{25}. $$

Since \(\frac{54}{25}<\frac{59}{25}\), choose \(x=3\). The derivative signs establish that integers further from the minimum on either side cannot improve on their nearer candidate. Substituting \(x=3\) into the original expression gives \((\frac{2}{5})^2+2=\frac{4}{25}+\frac{50}{25}=\frac{54}{25}\), confirming the selected value.

When a Feasible Boundary Determines the Answer

The neighboring-integer rule above assumes the continuous peak \(c\) lies in the interior of the interval. In applications, the unconstrained peak can lie outside the feasible interval. Then the objective might be increasing or decreasing throughout the feasible range, and the feasible integer nearest the appropriate boundary can be optimal. The boundary itself may not be an integer, so compare feasible integer choices rather than treating that real boundary as an allowed decision.

Worked Example: The Best Integer Lies at a Feasible Boundary

Maximize \(h(x)=-(x-5)^2+12\) over integer \(x\in[1.2,4.6]\). The feasible integers are \(2,3,4\). The derivative is \(h'(x)=-2(x-5)\), which is positive throughout the interval because \(x<5\). Thus the objective increases across the feasible interval, and its greatest feasible integer is \(4\). To verify the choice, compare the objective values:

$$ h(2)=-(2-5)^2+12=3,\qquad h(3)=-(3-5)^2+12=8,\qquad h(4)=-(4-5)^2+12=11. $$

The largest value is \(11\), attained at \(x=4\). The continuous peak \(x=5\) is outside the feasible interval, and the right endpoint \(4.6\) is not an integer decision. Substitution of \(x=4\) into the original objective gives \(-(4-5)^2+12=-1+12=11\), confirming the maximum.

Why Rounding Alone Can Fail

It is tempting to round a continuous optimum to the nearest integer and stop. That shortcut is not generally justified: a function can have a strict continuous peak and still lose value more rapidly on one side than on the other. The nearest integer need not give the greater objective value. The following calculation shows why the two neighbors must be compared.

Worked Example: The Nearest Integer Is Not Always Best

On the integer decisions \(x\in\{0,1\}\), consider \(p(x)=-\frac{t^2}{2}+\frac{t^3}{2}\), where \(t=x-\frac{49}{100}\). As a function of \(x\), its derivative is:

$$ p'(x)=-t+\frac{3t^2}{2} =-t\left(1-\frac{3t}{2}\right). $$

For \(0\le x\le1\), \(t\) ranges from \(-\frac{49}{100}\) to \(\frac{51}{100}\). The factor \(1-\frac{3t}{2}\) is positive throughout this range; even at the largest \(t\), it is \(1-\frac{153}{200}=\frac{47}{200}>0\). Therefore \(p'(x)>0\) before \(c=\frac{49}{100}\) and \(p'(x)<0\) after it. The continuous maximum is at \(c=0.49\), whose nearest integer is \(0\). But the two feasible integer values are:

$$ p(0)=-\frac{357749}{2000000}, \qquad p(1)=-\frac{127449}{2000000}. $$

Since \(-\frac{127449}{2000000}>-\frac{357749}{2000000}\), the better integer is \(1\), not the nearest integer \(0\). These values come from substituting \(t=-\frac{49}{100}\) and \(t=\frac{51}{100}\), respectively, into the definition of \(p\). This example confirms that even when the continuous peak is known, comparing the neighboring feasible integers is essential.

A Practical Comparison Procedure

For an integer decision constrained to a closed interval, first identify the feasible integers. If the set is nonempty and small, evaluate the objective at every feasible choice. If calculus reveals a strict interior maximum or minimum with the derivative signs described above, evaluate the feasible integers immediately to either side of the continuous optimum. If that optimum is outside the interval, check the feasible endpoint choices and use the derivative behavior to determine whether the objective is increasing or decreasing across the range.

These shortcuts depend on the objective's shape and on the feasible set. If the integer constraints leave gaps, or the objective is not increasing up to one peak and decreasing after it, the floor-and-ceiling result may not apply. In that case, compare the feasible candidates justified by the actual constraints and objective; do not assume that the nearest integers to a continuous critical point settle the problem.

Common mistake: Finding a continuous critical point and reporting it as the discrete answer, or rounding it without comparing objective values. Correct the mistake by checking feasibility first, identifying the relevant feasible integer candidates, and evaluating the original objective at each one.

Check Your Understanding

Use the derivative behavior and feasible integer set to decide which values must be compared.

  1. A function increases before \(c=4.3\) and decreases after \(c\). If the integer feasible set is \(\{1,2,\ldots,8\}\), which candidates suffice to find its maximum?
  2. Why does a theorem about a maximum over feasible integers need to assume that at least one feasible integer exists?
  3. A continuous minimum occurs at \(c=6.7\), with the function decreasing before \(c\) and increasing after it. Which neighboring integers should be checked if both are feasible?
  4. If the continuous maximum lies to the right of every feasible integer and the objective is increasing throughout the feasible interval, which feasible integer is best?
  5. Why can rounding a continuous optimum to the nearest integer fail, even when the function has a strict maximum there?

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon