Are two mathematically alike functions equal?

Yes, the functions are equal. The choice of $x$ or $y$ (or any other symbol) doesn't carry any meaning; those are what are sometimes referred to as dummy variables (link to MathWorld). I could define $h:\mathbb{R}\to\mathbb{R}$ by $$h(\&)=\& ^2$$ and then $h$ would again be the same function as $f$ and $g$.


More generally, if $A$ and $B$ are sets, then a function from $A$ to $B$ is usually defined formally to be a subset $R\subseteq A\times B$ such that, for all $a\in A$, there is exactly one element of $R$ whose first entry is $a$. The collection of all functions from $A$ to $B$ is usually written $B^A$. Under this system, $f$ refers to the subset $$\{(x,x^2):x\in\mathbb{R}\}\subset \mathbb{R}\times\mathbb{R}$$ and $g$ refers to the subset $$\{(y,y^2):y\in\mathbb{R}\}\subset \mathbb{R}\times\mathbb{R}$$ But the subsets are the same, since they have the same elements! $\,(3,9)$, $\,(-1.1,1.21)$, $\,(\pi,\pi^2)$, etc., all the elements of one are elements of the other and vice versa. By the axiom of extensionality (Wikipedia) they are equal. This more formal argument is what Andrea Mori's answer is about.


A function $f:\Bbb R\rightarrow\Bbb R$ can be seen as a (certain) subset of $\Bbb R^2$ (Note: in fact the functions are usually defined to be certain subsets, but you can ignore this now)

Two functions are the same when the corresponding subsets are the same. The names you choose for the coordinates in $f:\Bbb R\rightarrow\Bbb R$ are irrelevant.


In elementary schools these days students might see the function described this way $$ f(\quad) = (\quad)^2 $$ or $$ f(\text{weird symbol}) = (\text{weird symbol})^2 $$ so when they get as far as you they wouldn't have to ask this good question.