# Is using DeclareMathOperator for functions the right thing to do? [duplicate]

I'm wondering if I use the \DeclareMathOperator for the wrong things.

For example I have a cost function cost(x,y) which takes two arguments. I would declare it as \DeclareMathOperator*{\cost}{cost} and use it later with $\cost(x,y) = ...$.

If this is correct, why do I never see the function f(...) typeset in roman? If it's not correct when should the \DeclareMathOperator* be used instead?

## marked as duplicate by Joseph Wright♦Jan 3 '15 at 21:11

• I would say that f is a "variable function", with no pre-defined meaning, contrary to log, abs, dom, tr, sgn, etc. But the question is worth asking, to me. – Clément Jul 10 '14 at 20:39
• You don't want the *, for such an operator. The generic “f” for functions is a variable, so it surely is in italics. – egreg Jul 10 '14 at 20:39
• There are two reasons or criteria for using \DeclareMathOperator (and its "starred" version, \DeclareMathOperator*): First, you wish to typeset its name in roman rather than italic -- as is customary with sin, cos, exp, log, det, etc. Second, you may wish to position the operator's argument either immediately below or in a subscript position to the right of the function name, as in \max_{x}f(x). "Generic" function names, such as f and g, probably don't satisfy either criterion. – Mico Jul 10 '14 at 20:40
• @egreg @Clément So because in my case cost is not a variable function you would say I can use the \DeclareMathOperator command? – user2653422 Jul 10 '14 at 20:47