While doing a math question on piecewise functions, I came across an answer which seemed wrong to me but I could not explain it mathematically.
The question states (summarised):
A lottery dealer makes 6 cents on each ticket sold. If the lottery dealer sells more than 25,000 tickets, she gets an extra 2 cents for every ticket after the 25,000th ticket. Express her profits as a function of the number of sold tickets.
The correct (or expected) answer was the piecewise function: $$ f(x) = \begin{cases} 6x, & \text{when } 0 \le x \le 25000 \\ 8x-50000, & \text{when } x \gt 25000 \end{cases} $$
However, another answer I saw was:
$$ \text{let } x \text{ be the number of tickets sold } \le 25000 \\ \text{let } z \text{ be the number of tickets sold } \gt 25000 \\ f(x) = 6x + 8z $$
I found this answer intuitively incorrect. To me, all mathematical functions are pure (a concept from programming). In particular, all values in a function should not be determined by anything other than it's inputs.
In this case, $f(x)$ is defined with an extra $z$ which is not given as an input.
But this is a concept from programming, not mathematics. After reading the definition of a function on Wikipedia, I don't see anything that explicitly says that additional variables are allowed or not allowed in function definitions.
Is there something I missed in the definition or is the second answer acceptable?
EDIT
To clarify and amplify the problem, here is another example. Let's say I want to define a function that adds $x$ to the current hour (in 24 hours). For example,
$$ \text{let } t \text{ be the current 24 hour time, } 0 \le t \le 23, t \in \mathbb{Z} \\ f(x) = t + x $$
Similar as before, this introduces a variable $t$ that is not given as an input to $f(x)$.
My question is this: What part of the mathematical definition of a function disallows this?