TITLE: Is the degree of a finite morphism stable by base change 
QUESTION [10 upvotes]: Let $f:X\longrightarrow Y$ be a finite morphism of schemes of degree $n$. Let $S\to Y$ be a morphism of schemes.
Is the degree of the finite morphism $X\times_Y S \longrightarrow S$ equal to $n$?
If not, what conditions should be put on $X$ and $Y$?
If it helps, you can assume all the schemes to be integral.

REPLY [19 votes]: I shall assume that $X,Y$ are integral,  locally noetherian schemes and that $f$ is dominant. Then the degree of $f$ is the degree of the corresponding  extension of fields, namely
$$deg(f)=[Rat(X):Rat(Y)]$$. 
We have for the fibers  $X_y \; (y\in f(X))$ of $f$ the interesting result: 
$$dim_{\kappa (y)} \mathcal O(X_y)\geq  deg(f)$$ 
with equality for all fibers 
$$    dim_{\kappa (y)} \mathcal O(X_y)=  deg(f)   \quad (\star)$$
if and only if $f$ is flat (cf. Qing Liu's book, page176).
So non flat morphisms will give you counterexamples by taking for  $S$ a point of $Y$.
For an explicit counterexample, consider the case where $Y$ is a node, $X$ the affine line (both over a field $k$) and $f$ the normalization morphism. This is a finite morphism of degree one, but the fiber of the singular point has degree $2$ over $k$.
More generally, normalizations of non-normal varieties are never flat and will yield any number  of countereamples.
Also if $f$ is flat the criterion will tell you, since flatness is preserved under base-change,  that the degree of $f$ will be  preserved under some reasonable assumptions on the morphism $S\to Y$, the most obvious one being that $S$ should be locally noetherian and integral too.
A well-known formula Here is an arithmetically flavoured  illustration of the above.
 Let A be a Dedekind domain with fraction field $K$  and  $L$ a separable  field extension of $K$ of degree $[L:K]=n$. Let $B$ be the ring of elements in $L$ integral over $A$.
That  ring $B$ is flat over $A$ (because for Dedekind rings flat=without torsion) and is a Dedekind domain, finite over $A$ (Krull-Akizuki).
 We can apply the considerations above above to the associated morphism $f:Spec(B)=X\to Y=Spec(A)$.
Take  a nonzero prime $\mathfrak p =y \in Y $ and write ${\mathfrak p}B=\prod {\mathfrak P}_i^{e_i}$.
Since $X_y=Spec(B/{\mathfrak p}B) $, the formula $(\star )$ translates into the very classical formula of algebraic number theory (where $f_i=[B/{\mathfrak P}_i: A/ \mathfrak p]$): 
$$n=\sum e_if_i$$