Let $f:X\to\mathbb A$ be a regular function on a scheme. Is there some relation between $f$ being a non-zero divisor in $\mathcal O(X)$ and the denseness (topologically or scheme theoretically) of $D(f)$ in $X$?
The motivation is that I am wondering in which sense the sheaf $\mathcal K_X$ on an arbitrary scheme is actually a "sheaf of rational/meromorphic functions" on $X$. Is the domain of definition on $f\in \mathcal K_X(U)$ dense in $U$?
Edit. Or here is a better question. What goes wrong if we define $\mathcal K_X(U) = $ regular functions which are defined on a (schematically?) dense open subscheme $V$ of $U$, where $(V,f) = (V',f')$ iff $f$ and $f'$ agree on $V\cap V'$?
Edit 2. I should mention: The sheaf $\mathcal K_X$ is the sheafification of $U\mapsto \mathcal O(U)[\mathcal S(U)^{-1}]$, where $\mathcal S(U)^{-1}$ consists of the non-zero divisors. I was wondering why the sheaf $\mathcal K(X)$ is called the sheaf of meromorphic (or rational functions) on $X$. For me a rational function is a function which is defined on a dense open subspace (and has poles on the part where it is not defined). It seems like page 303 of Görtz&Wedhorn talks abut this. :)
I was unhappy with $\mathcal K_X$ because I did not see how a section $s\in \mathcal K_X(U)$ defines a partial function on $U$. But I have now seen a good explanation in Görtz & Wedhorn's book, so I am happy. Let me just give a short summary.
Let me use $\mathcal O$ to denote the contravariant functor $Hom_{Sch}(-,\mathbb A)$. An open subspace $U$ of a scheme $X$ is schematically dense iff for each open $V$ the smallest closed subscheme of $V$ which contains $U\cap V$ is $V$ itself. This is equivalent to $\mathcal O_X\to i_*\mathcal O_U$ being a monomorphism in $Sh(X)$.
A function $f:X\to \mathbb A$ on a scheme $X$ is a non zero-divisor if and only if the smallest closed subscheme of $X$ which contains $D(f)$ is $X$. If $X$ is an affine scheme, then $f$ is also regular on each basic open subscheme of $X$, and it follows that $D(f)$ is schematically dense. This is the connection between schematically dense and regular I was looking for.
It is not the case that $D(f)$ is automatically schematically dense when $f$ is a non-zero divisor. In fact, this is in essence one of the three misconceptions about $\mathcal K_X$ (see the citation below). Instead $D(f)$ is schematically dense if and only if $f$ is regular, that is if and only if it is a non-zero divisor in each stalk $\mathcal O_{X,p}$, or equivalently if $f$ is a non-zero divisor when restricted to each open subspace. The sheaf $\mathcal K_X$ is the sheafification of $$U\mapsto \mathcal O(U)[\mathcal S(U)^{-1}]$$ where $\mathcal S(U)$ consists of the regular elements of $\mathcal O(U)$. There is some clash of terminology with the other use of the word "regular function" here, so I will just say function for a morphism $X\to \mathbb A$.
A rational function on $X$ is a function on a schematically dense open subscheme of $X$ which can not be extended to a larger domain. Alternatively, it is an equivalence class of functions defined on schematically dense subspaces, where two such functions are equivalent if and only if they agree on the intersection of their domains. I write $\mathcal R(X)$ for the rational functions on $X$. The assignment $U\mapsto \mathcal R(U)$ defines a sheaf on $X$ which I denote by $\mathcal R_X$.
To get a morphism $\mathcal K_X\to \mathcal R_X$ it is enough to defined a map $\mathcal O(U)[\mathcal S(U)^{-1}]\to \mathcal R(U)$ for each open subscheme $U$ of $X$. But an element of the localisation may be written as a fraction $s/t$. The $t$ is regular and so $D(t)$ is schematically dense in $U$. The expression $1/t$ defines an actual function on $D(t)$, and so we can send the formal fraction $s/t$ to the equivalence class of the function $s/t:D(t)\to \mathbb A$. It is shown in Görtz & Wedhorn that the resulting map $\mathcal K_X\to \mathcal R_X$ of sheaves is an inclusion.
The image of $\mathcal K_X$ in $\mathcal R_X$ consists of those rational functions which may locally be written as a quotient. In that sense it is the case that $\mathcal K_X$ does maybe more deserve the name sheaf of rational functions then $\mathcal R_X$. The inclusion is an isomorphism if $X$ can be covered by open affine schemes $Spec \, A$ which satisfy the following condition.
This is the case for example if $X$ is integral or locally Noetherian. See proposition 11.22. in Görtz & Wedhorn.
Kleiman, Steven L., Misconceptions about (K_x), Enseign. Math., II. Sér. 25, 203-206 (1979). ZBL0432.14013.