Why do you have to define that a specific value in a function is undefined? While teaching us about limits, my math teacher showed us how to define a function with a "hole" in it:
$$f(x)=\begin{cases}x^2, & x \neq 2 \\ \text{undefined}, & x=2\end{cases}$$
This is really confusing me, why do I have to define that a value is undefined?
I asked her, and her reasoning is that if you don't write that for $x=2$ there is no value, then it could be any value possible, like $7$ or $42$ as the function has only be written partially. She added that it is only I who thinks that it is undefined, for everyone else, it could be anything, and thus, I have to explicitly write that the function has no value for $2$, or else it wouldn't be mathematically correct.
I don't understand the reasoning for the following reason: If I write 
$$f(x)=x^2, \text{ for } x\neq 2$$
then the function is already undefined for the value is $2$, as the function has no formula if $x=2$. And thus, the value is undefined, I don't have to write it again that it is in fact undefined.
After a while, she dismissed me by saying that it is only a formality, and as a result not important.
But I really want to know, so where is my flaw? Or rather, why do I have specify that the function is undefined for $2$ explicitly?
 A: You are completely right, although it is better to replace
$$f(x)=x^2, \text{ for } x\neq 2$$
by
$$f(x)=x^2, \text{ for } x\in\mathbb R\setminus\{2\}.$$

More explicitly: To write "undefined" simply makes no sense.


As a complement, a function is defined only if we give a domain and an expression for it. However, sometimes it is impossible to indicate an explicit expression and the same happens for the domain. Look for example at the apparently "peculiar" way in which the domain of an infinitesimal generator is defined (see https://en.wikipedia.org/wiki/C0-semigroup#Infinitesimal_generator). But really, your class seems to be of a more basic level, and so all this should be forgotten.
A: A relation between sets $A$ and $B$ is a subset of the Cartesian product $A\times B$.
A function is a relation with the property that for all $a\in A$, $\exists b\in B$ such that $f(a)=b$ such that for a given $a$, such a $b$ is unique.
The set $A$ is called the domain of the function, and the set $B$ is called the codomain. Every element in the domain must have a mapping of the function in the codomain. Thus, a function needs to be defined everywhere in its domain.  A function $f$ with a domain $A$ and codomain $B$ is denoted as $$f:A\to B$$
So, first, in your case, you need to define the domain of your function. If your domain is $\mathbb R\setminus \{2\}$, then it is implied that you talk of the definition of the function only in points that lie in its domain. If your domain includes $\{2\}$, and the function has no mapping to the codomain, your function is not a function at all by definition, it is just a relation.
Either way, there is no need to mention "undefined" anywhere explicitly.
A: Every function have to be defined among others by its' domain, eg:
$$f:[-1,3]\to \mathbb{R},\\ f(x)=x^2$$
If you specify the domain (in this case it is an interval $[-1,3]$), you don't have to point, that $f$ is undefined for $x\not \in [-1,3]$.
On the other hand your teacher showed the alternative way to determine the domain - pointing, that for values from some set the function is undefined:
$$f(x)=\begin{cases}NaN&,x <-1\\x^2&,x\in[-1,3]\\NaN&, x>3\end{cases}$$
Frankly speaking this is the first time I see, that math teacher taught someone to do it in that way - it's very... unesthetic.
