# What is the constant function, exactly?

There is a big discussion in our class.

Teacher says,

$$f:\mathbb Z^{+}\rightarrow \left\{0\right\}$$ and $$f(x)=0$$ is a constant function.

But, student says only

$$f:\mathbb R\rightarrow \left\{0\right\}$$ and $$f(x)=0$$ is a constant function

or $$f(x)=0\,\,\forall x\in\mathbb R$$

Unfortunately, wikipedia doesn't cover this problem.

What is the right statement?

• Dec 3 '21 at 13:35

Both are constant, the difference is just the domain, that is, the values your function is allowed to take as input. It is constant in so far as the output is always the same no matter what the input is, and this value doesn't have to be $$0$$, it can be anything else as long as it's the only value the function can output.

Sure, in the function given by the teacher, $$f(-2)$$ will be undefined, but saying it like that is misleading. The value $$-2$$ is not part of the domain, $$f$$ can't accept $$-2$$ as input, it's not as if $$f(-2)$$ existed but had some weird undefined value, it just doesn't exist at all. So the function effectively only outputs one value, in this case it's $$0$$. I hope I'm making sense and not confusing you further.

EDIT (can't comment on other posts) : @Angel I think what they mean by "$$f : \mathbb{Z} \rightarrow 0$$ means $$f(x) = 0$$ not for all $$x$$" is "the value of $$f$$ isn't $$0$$ for all $$x$$ since there are values of $$x$$ (outside of the domain) where $$f$$ isn't defined and as such for which $$f(x)$$ isn't $$0$$". A confusion about what functions and domains are, and the teacher probably has an habit of writing $$\forall x$$ instead of $$\forall x \in \mathbb{R}$$ which might lead to further confusion about what "for all" means in general.

• Yes, now I understand..thank you. Dec 3 '21 at 13:26
• @Uretki I see, that makes sense. That would be where the confusion stems from, and if so, then I agree with you. This clarifies it. Dec 3 '21 at 13:35

A constant function is a function which is constant. That is $$f(x)=c$$ for all $$x$$ and some $$c$$. There is no reason to restrict this definition to the case where $$c,x\in\mathbb{R}$$ and $$f:\mathbb{R}\to\mathbb{R}$$.

• Well, who is right? Dec 3 '21 at 13:02
• @I'mastudent Did you not read the answer? The teacher is right. Dec 3 '21 at 13:06
• $f:Z\rightarrow 0$ means, $f(x)=0$ not forall $x$. Dec 3 '21 at 13:15
• "There is no reason to restrict this definition to the case where..." And yes, the definition of a constant function is a function such that there is some $c\in{Y}$ such that $f(x)=c$ for all $x\in{X}.$ Dec 3 '21 at 13:17
• @I'mastudent No, that is definitely not what that means, and I have no idea where you get that from. Dec 3 '21 at 13:18