# If two functions are defined by the same formula, but have different codomains, are they equal?

It is said for two functions $f,g$ to be equal they must have same domain and codomain and for each $x\in X$, $f(x)=g(x)$.

But shouldn't functions such as $f:\Bbb R \to \Bbb C$ where $f(x)=x^2$ and $g:\Bbb R \to \Bbb R$ where $g(x)=x^2$ still be considered equal functions for example? Even if codomain is different.

• Equality of functions is a definition. There is no "should." – Paul Apr 24 '18 at 12:36
• @JimmySabater This is fine, in the example given just take $u(x) = x^2$ and $v(x) = 0$. – JackR Apr 24 '18 at 12:37
• Functions are defined as subsets of the Cartesian product of the domain and the co-domain (with certain properties). In your case $f$ is a subset of $\mathbb{R}\times\mathbb{C}$ and $g$ is a subset of $\mathbb{R}\times\mathbb{R}$. And those subsets are the same (well, if $\mathbb{R}$ is seen as a subset of $\mathbb{C}$). In general, from the definition of function you see that the function doesn't really depend on the co-domain. But there are contexts in which it is useful to consider the co-domain, part of what a function is. This happens when the sets are the subject matter of the study. – user551819 Apr 24 '18 at 12:39
• On the other end of things, you could bite the bullet and do away with the horrible ambiguity that is the codomain. Let $i:\mathbb{R}\to\mathbb{C}$ be the function $a\mapsto a+0i$. Then $f=i\circ g$. – Prototank Apr 24 '18 at 12:39
• @Paul Actually, definitions should serve their usage. Moreover, the particular case of equality of functions does have two different versions, depending on the context, one in which his two functions are the same and one in which they are not. – user551819 Apr 24 '18 at 12:56

We usually construct $\mathbb{C}$ as an ordered pair $(x,y) \in \mathbb{R} \times \mathbb{R}$, and define multiplication on these pairs. Here $x$ is the real part of the complex number and $y$ is the imaginary part. We have a natural isometric embedding of $\mathbb{R}$ into $\mathbb{C}$ by $x \mapsto (x,0)$. Thus, if we're talking about the real number "$2$" in $\mathbb{C}$, we're really talking about the ordered pair $(2,0)$.
To bring it back, the two functions you described: $$f:\mathbb{R} \rightarrow \mathbb{R}, \quad f(x) = x^2$$ $$g:\mathbb{R} \rightarrow \mathbb{C}, \quad g(x) = x^2$$ Obviously $f$ and $g$ give the "same information" in some sense, but the objects in the image are set theoretically distinct, even if we interact with them in exactly the same way.
Some authors define function equality differently: if the domains are the same, and the rules of association are the same, the functions are the same. If $f(x)=x^2$, but you also write $f:\mathbb{R}\to\mathbb{C}$, you're not really gaining a whole lot. Also recall what a function actually is, at a fundamental mathematical level: it's a set where the elements look like ordered pairs $(x,f(x))$. If the sets corresponding to two functions are the same, the functions are the same.