The Vending Machine's Glitchy Pricing
A campus vending machine charges $1.75 per snack. During a software glitch, the machine rounds the total cost to the nearest dollar (rounding halves up) before charging. A student buys 3 snacks and pays $5.00, while a friend buys 4 snacks and pays $7.00. The machine's display also shows a running count of items dispensed, but the count resets to 0 whenever the power flickers. On Tuesday the power flickered twice. The student wants to model the amount charged as a function of the number of snacks purchased, and also wants to know whether the total amount collected on Tuesday can be determined from the item count alone.
1. Define a function C(n) that gives the amount charged for n snacks under the glitch, and determine whether C is one-to-one. Justify from the rounding rule.
Read the worked answer
Exact cost is 1.75n; charged amount is C(n) = round(1.75n) with halves rounded up.
Compute: C(1)=2 (1.75 rounds to 2), C(2)=4 (3.5 rounds up to 4), C(3)=5 (5.25→5), C(4)=7 (7.0→7), C(5)=9 (8.75→9), C(6)=11 (10.5→11), C(7)=12 (12.25→12), C(8)=14 (14→14).
C is not one-to-one: C(3)=5 and C(4)=7 differ, but note C(1)=2 and no other n gives 2; however C(2)=4 and C(3)=5, C(4)=7, C(5)=9, C(6)=11, C(7)=12, C(8)=14. Check for repeats: since 1.75n increases by 1.75 each step and rounding to nearest integer, consecutive outputs can repeat when the fractional part stays within the same integer. E.g., C(7)=12 and C(8)=14 - no repeat there. But C(5)=9 and C(6)=11. Actually repeats occur: as n grows, 1.75n mod 1 cycles with period 4 (since 1.75=7/4). Values 1.75n for n=0,1,2,3 give fractional parts 0, .75, .5, .25. Rounded: 0,2,4,5; n=4 gives 7. No two consecutive n map to same integer because gap 1.75 > 1. But non-consecutive: C(n)=C(m) requires |1.75(n−m)|<1, i.e., |n−m|<0.571, so only n=m. Hence C is one-to-one on nonnegative integers. Correct conclusion: C is one-to-one because the step 1.75 exceeds 1, so distinct n give distinct rounded values.
2. The item count on Tuesday reads 37 after two resets. Can the total collected be recovered? Explain using function composition and the reset behavior.
Read the worked answer
The displayed count is not the true number of items sold; it is the count since the last reset. If resets occurred at unknown times, the display value 37 equals items sold since the second reset, not the total. The total collected is C(n₁)+C(n₂)+C(37) where n₁+n₂ is the number sold before resets, which is unknown. Since C is one-to-one, each segment's charge is recoverable if each segment count were known, but the pre-reset counts are lost. Therefore the total cannot be determined from 37 alone. This illustrates that composition C∘(count) is only invertible when the count function is injective over the whole day; the reset makes the count non-injective (many true totals map to displayed 37).