Consider the diagonal $D= \{(w,x,y)\in \mathbb{A}^{3n}:w=x=y\}$. We can work with field $k$, where $k$ is not necessarily closed, for example $\mathbb{R}$ (maybe let's just work with $k=\mathbb{R}$). We impose the Zariski topology on $\mathbb{A}^n=k^n$ (and on $k^{3n}$). Then how can we compute the dimension of $D$? The definition of dimension of a topological space $X$ is the following:
Let $X$ be a topological space. A chain of subsets of $X$ is a sequence $X_0\subset X_1 \dots... \subset X_n$ such that the $X_i$ are distinct. Such a chain is said to be of length $n$. The dimension of $X$ is the maximum of the lengths of chains of irreducible closed subsets of $X$.
In case $k= \mathbb{R}$, it seems that observing that $D= V(f)$ is probably relevant, where $$f(w,x,y)=\sum_{i=1}^n(w_i-x_i)^2+\sum_{i=1}^n(x_i-y_i)^2+\sum_{i=1}^n(y_i-z_i)^2.$$
I expect the dimension to be $n$ but how do I prove it?
Secondly, let $W=\{(x,x,x)\in \mathbb{A}^n|\nabla g(x)=0\}$ for some homogenous polynomial $f$.
If $g$ is non-singular (i.e. the Jacobian is not zero), what is the dimension of $W$?
I don't really know any algebraic geometry, so I would appreciate a hint or two. I have no clue as to which theorems are pertinent/useful at all, nor any intuition for dimension. Thanks!