# When should math be upright?

Is there any standards for when math is supposed to be upright?

E.g.

The f in f(x) is in italics but cos in \cos x is upright. As I see it, both are functions?

\int f(x) \, dx OR \int f(x) \, mathrm{d}x?

P(Y=y) OR \text{P}(Y=y) OR p(Y=y) OR \text{p}(Y=y) for probabilities?