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.
 A: It might be worth noting that from a set theoretic standpoint, the copy of the reals contained in the complex numbers is not the same set as the reals on their own. They are isomorphic, but distinct as sets.
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. 
A: 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.
