According to texdoc symbols: \mvert and \mid are identical and produce a relation. \vert is a synonym for | and both produce the same symbol, but should be used in the context of an ordinal, and should be used as an operator, not as a delimiter (p54, bottom). \divides once again produces the same symbol but should be used as a binary “divides” operator. \lvert and \rvert are left and right ...
The first problem can be solved, superficially, by changing \vert to \middle\vert. Fixing the second problem requires inserting ; ("thickspace") on either side of \middle\vert. Entering the full expression can be streamlined, to a degree, by defining a macro \f as follows:
How can I change the size of \vert accordingly like \left and ... - TeX
In short, \bigl\vertmath mode - Use \big\vert f (x) \big\vert or `\big\lvert f (x) \big ...
The vertical bar produced by | or \vert has TeX math type "ordinary", meaning that no special meaning is attached to it. Quite often, though, it's necessary to inform TeX that the bar does have a special meaning. If the bar acts as a separator between some expression and the conditioning event, as in "the conditional density of Y given x", you should use \mid: doing so generates a vertical bar ...