My high-school textbook states the following definition:
Two functions $f(x)$ and $g(x)$ are said to be identical iff:
$D_f$ = $D_g$
$f(x) = g(x), \forall x \in D $
By this definition functions $f: \mathbb{R} \rightarrow \mathbb{R}, f(x) = x^2$ and $g: \mathbb{R} \rightarrow [0, \infty), g(x) = x^2$ are identical. However, the second one is surjective while the first one is not. So, how can the two functions be called identical if one is surjective while the other one is not?
Is this the correct definition of identical functions or is this an oversimplification for the high-school level?
My instructor said that the most accurate definition should be:
Two functions $f(x)$ and $g(x)$ are said to be identical iff:
$D_f$ = $D_g$
$f(x) = g(x), \forall x \in D $
Codomain of $f$ = Codomain of $g$
I want to ask which definition is more accepted and followed at higher levels like in real analysis.