1

Can a parameter of a function be NULL like in the example below?

$ f_{AE}(t_x;i_1;i_2;p)= \begin{cases} \hfill \frac{\displaystyle\sum_{k=i_1}^{i_2} R_s(e_{c_k,t_x};a_k)}{p} \hfill & \text{if $p \neq NULL \land R_s(e_{c_k,t_x};a_k)= p$} \\ i_2 - i_1 \hfill & \text{if $p = NULL$} \\ \end{cases} $

Call option 1:

$f_{AE}(t_1;5;10)$

Call option 2:

$f_{AE}(t_1;5;10;5)$

Or do I need two completly separate functions with different parameters?

thx

Stev
  • 15
  • Do you mean 0 (zero) or some non-numeric value? What domain is $p$ taken from? – cfh Sep 23 '15 at 14:27
  • NULL just implies that p does not have a value. I'm assuming this function has something to do with programming, where a variable can take on a NULL value (a funny way of saying it doesn't have a value). – Poisson Fish Sep 23 '15 at 14:31
  • I want to call the function like f(p1;p2;p3) and f(p1;p2;p3;p4). So sometime I want to use it with 3 and sometime I want to use it with 4 parameters. If I only use it with 3, the fourth parameter would be NULL. I think more like a programmer than a mathematician :P – Stev Sep 23 '15 at 14:31

2 Answers2

1

The inputs to a function can come from any set you like. There is nothing wrong with saying $p$ belongs to say, the set

$$\{\text{NULL}, 5,\}$$

But of course, care is needed to make sure you have a well-defined function.

[edit] I see from the comments that you don't just want it to be NULL, you want to completely omit the parameter.

You can do this if you tell your audience that you are doing it, but it is highly non-standard. This is because mathematicians have been taught to curry :) e.g. $A$ is a matrix/linear map, and $A(x)$ is a vector.

Calvin Khor
  • 34,903
  • Haha ok thanks. So you mean I should rename the function because A is a matrix? – Stev Sep 23 '15 at 15:04
  • No, let me try a better example. Say we have a function $A : ℝ \times ℝ → ℝ$. If you give it only one input, $x$, then one would normally think of $A(x) : ℝ → ℝ$. i.e. we also think of $A$ as the curried function $A:ℝ → (ℝ → ℝ)$. This function takes in a single input, and gives you a function $ℝ→ℝ$. This is very different behaviour from what you were asking it to do. In mathematics, you can do whatever you want as long as you define it beforehand. But I think it will catch a few people off-guard. – Calvin Khor Sep 23 '15 at 15:08
  • 1
    @Stev an example that is like yours is $$ f:ℝ\times(ℝ∪{}) → ℝ,\ f(x,y) = \begin{cases} xy & y ≠ \ π & y=\end{cases}$$and then we already have one common interpretation, $$ f(x) : ℝ ∪ { }→ℝ ,\ f(x)(y) = \begin{cases} xy & y ≠ \ π & y=\end{cases}$$ So to also define $f(x) := f(x,)∈ℝ $ will require you to state explicitly and carefully what you are doing. – Calvin Khor Sep 23 '15 at 15:14
  • Ok, got it :) Thank you very much for your efforts – Stev Sep 23 '15 at 15:26
  • I'm just happy to use in a serious answer. :) – Calvin Khor Sep 23 '15 at 15:28
  • +1 for the :D (and the good example, I suppose, but mostly for the ) – Poisson Fish Sep 23 '15 at 18:17
0

The short answer is YES, $p$ can take on the "value" NULL for the function you have provided.

For this function, you have allowed $p$ to contribute to the value if and only if it is not NULL. This implies that it has a value in your domain.

If $p$ is NULL, it should not contribute to the value of the function, because it wouldn't make any sense. Consider $$1+NULL = ???,$$ which is meaningless. Most computer languages interpret any math using NULL to equal NULL, so that

$$1+ NULL = NULL.$$

This is accounted for in your function by making the function equal $i_2-i_1$ when $p$ is NULL, which does not depend on $p$.

  • Ok sounds good. But than I have to call the function like f(1,4,NULL). I can't ignore the parameter like f(1,4)? – Stev Sep 23 '15 at 14:45
  • Yes, I would call it like f(1,4,NULL). You don't want to cause confusion by dropping the variable altogether. More importantly, if you are doing this on a computer, you will need to tell the computer that p is NULL. – Poisson Fish Sep 23 '15 at 14:48