Let $R$ be a commutative ring with $1$, and let $f \in R$ be an element of $R$ which is neither nilpotent, nor a unit (assuming there exists such an element in $R$). Let $R_f$ be the localization of $R$ with respect to the multiplicative subset $\{ f^n: n \in \mathbb{N} \}$. In this post, the relevant notion of dimension used is *Krull dimension*.

It is clear that $\dim R_f \leq \dim R$. I have two questions:

1) Are there some sufficient conditions that ensure equality of the dimensions, namely sufficient conditions to have $\dim R_f = \dim R$?

2) Does equality hold in general? If yes, can someone provide a proof please, and if not, can someone provide an example where $\dim R_f < \dim R$?

**Edit 1:** Following user26857's comment, let $R = \mathbb{C}[x]_{(x)}$. Let $f=x/1$. It is clear that $\dim R = 1$; indeed the only prime ideals of $R$ are $0$ and $(f)$. It follows easily that $\dim R_f = 0$, since the only prime ideal of $R$ which avoids the non-negative powers of $f$ is $0$. This answers my question 2, because in this example, we have $\dim R_f < \dim R$. (Remark: I had written a wrong example in my answer before, instead of this one, for which I apologize.)

**Edit 2:** Regarding question 1), following Mohan's comments, if $R$ is an integral domain which is a finitely generated algebra over a field or $\mathbb{Z}$, and if $f \in R$ is nonzero, then

$\dim R_f = \dim R$.

We thus have 2 cases to consider in this claim

case A: $R = k[x_1,\cdots,x_n]/P$, where $k$ is a field, and $P$ is a prime ideal in $k[x_1,\cdots,x_n]$.

case B: $R = \mathbb{Z}[x_1,\cdots,x_n]/P$, where $P$ is a prime ideal in $\mathbb{Z}[x_1,\cdots,x_n]$.

I will be happy if someone can post as answer a sketch of a proof of Mohan's claim. I think it amounts to showing that one can find a sequence of chains of prime ideals in R, with all prime ideals involved not containing $f$, and whose lengths go to $\dim R$.