3
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ For each element $x$ in the domain of the function, there is associated one value $f(x)$ in the range. $\endgroup$ Jun 15, 2018 at 11:37
  • $\begingroup$ I understand that that is the definition of a function, however, what part of that definition keeps me from saying that $f(x) = 6x + 8z$? And then I define $z$ as some variable $\endgroup$ Jun 15, 2018 at 11:43
  • $\begingroup$ In this case it's possible to rewrite the equation as a function of a new variable $n$, which is just the tickets sold. Then we have the transformations $x= \max{(25~000- n,0)}$ and $z = \max{(n-25~000, 0)}$ and therefore the function is indeed a function of only one variable. $\endgroup$
    – Matti P.
    Jun 15, 2018 at 11:44
  • $\begingroup$ You'd call it $f(x,z)$ if you want another variable $z$. Then it's a function on ordered pairs $(x,z)$. Of course you still have to make sure there's still only exactly one $f$ value associated with every ordered pair input (x,z) $\endgroup$
    – N8tron
    Jun 15, 2018 at 11:45

3 Answers 3

4
$\begingroup$

In $f(x) = 6x + 8z$ you have used $x$ to mean both the number of tickets sold in total and the number if below $25000$ (and presumably $0$ otherwise). This is not satisfactory

We could attempt a recovery. First let $x$ be the number in total and $y$ the number in excess of $25000$, which from the question would give $f(x)=6x+2y(x)$

We can actually write down $y$ explictly as $y=\max(x-25000,0)$ and that would give a single line closed form of $f(x)=6x+2\max(x-25000,0)$ which can be written as $$f(x)=\max(8x-50000,6x)$$

$\endgroup$
2
  • $\begingroup$ I understand that the second answer is unsatisfactory, in that it should not done in that way. However, my question is more broad. If I were to define $z$ as a variable based off something else, unrelated to $x$, and use it in the function, what is wrong (if any) with that? What part of the definition of a function does it violate? $\endgroup$ Jun 15, 2018 at 11:54
  • $\begingroup$ Functions send each value of their domain to a a value of the co-domain. The question asks for a function perhaps from the non-negative integers to real numbers, while $f(x)=6x+8z$ seems to send values in $[0,25000)$ to functions of $z$. You can try that if you want but will need to be careful in describing what you are doing, and may still be rejected as being excessively complicated $\endgroup$
    – Henry
    Jun 15, 2018 at 12:01
2
$\begingroup$

This other answer is indeed a little clumsy but not unrecoverable.

The problem indisputably has a single input variable, the number of tickets sold, which is denoted by $x$.

Now consider

$$ \text{let } \color{green}y \text{ be the number of tickets sold } \le 25000 \\ \text{let } z \text{ be the number of tickets sold } \gt 25000 \\ f(x) = 6\color{green}y + 8z $$ or better

$$ \text{let } y\color{green}{(x)} \text{ be the number of tickets sold } \le 25000 \\ \text{let } z\color{green}{(x)} \text{ be the number of tickets sold } \gt 25000 \\ f(x) = 6y\color{green}{(x)} + 8z\color{green}{(x)}.$$

The "impurity" is gone (though we can still discuss the intelligibility of the definitions of $y$ and $z$).

The main sin here was to use $x$ with two different meanings. Introducing intermediate dependent variables/functions is harmless.


Update (after the EDIT):

It is common practice to use literal constants in function definitions. They are considered to belong to the context and any variation of their values are not relevant to the discussion in progress, so they can be implied.

For your example the correct defintion could be

$$f:x\in\mathbb R, t\in\{0,1,\cdots23\}:f(x,t)=x+t$$ but for conciseness omission of the second argument is allowed. (Think of $f'(x)$ vs. $\dfrac{\partial f(x,t)}{\partial x}$ when you don't care about the influence of time.)

The notation $f_t(x)$ can also be used, with the intent to stress that $t$ plays a different kind of role.

$\endgroup$
5
  • $\begingroup$ I have added another example to clarify. The main problem I would like to focus on is not that $x$ has two meanings (though that is quite a big problem), but that $z$, a variable, is involved. The example also uses a completely unrelated variable, $t$. $\endgroup$ Jun 15, 2018 at 12:26
  • $\begingroup$ Informally, you can see the constants as either literal symbols or global variables. $\endgroup$
    – user65203
    Jun 15, 2018 at 12:34
  • $\begingroup$ What do you mean by "literal" when you say "defined literal symbols" and "literal constants"? Are you referring to this literal? $\endgroup$ Jun 15, 2018 at 12:50
  • $\begingroup$ @MoonCheesez of course, like #define PI 4 $\endgroup$
    – user65203
    Jun 15, 2018 at 13:27
  • $\begingroup$ You mentioned that variations of their values are not relevant, but that's exactly what I mean! If these values vary, they should be included as an argument in a function. However, what part of the definition of a function (this one, not what $f(x)$ is) requires that? $\endgroup$ Jun 15, 2018 at 13:32
0
$\begingroup$

I'm going to address this part of your question, since the other answers have addressed the other parts:

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?

Well, some might object that the notion of "the current time" doesn't have any mathematical meaning. But let's set that objection aside.

The definition you've given is, in fact, the definition of a function, but it's the definition of a pure function. Specifically, given the time and place that I'm writing this, the function that you've defined is $f(x) = x + 17$. An hour from now, the definition will refer to a different function instead: namely, the function $f(x) = x + 18$.

All right, but let me give another attempt at defining an impure function. This time, I'm going to write something that really is an invalid definition:

$$g(x) = x + (\text{the current year, as of the time that this function is being evaluated})$$

I've attempted to define one function, $g$, where $g(10)$ is $2028$ right now, but will change to be $2029$ next year, and so on.

So, what part of the mathematical definition of a function disallows this? Well, here's one standard definition of a function:

Given sets $X$ and $Y$, a function $X \to Y$ consists of a subset $s$ of $X \times Y$, such that each element of $X$ appears exactly once as the left-hand component of an element of $s$.

To a software developer, a mathematical function isn't like a subroutine (or "function") at all. Instead, a mathematical function is essentially a mere list of input and output values (and each valid input must be listed exactly once). And there simply is no way for a mere list of input and output values to be an "impure function", because once you've determined what the function is, you've determined all of its outputs, too.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .