TITLE: Is it legitimate to write nested big-Os in an asymptotic formula for a multivariable function?
QUESTION [8 upvotes]: Suppose I have a 2-variable function $g(k,n)$ and I know that $g(k,n)=O(n^{f(k)})$, for fixed $k$ as $n \rightarrow \infty$, for some function $f=f(k)$.  Suppose I also know that $f(k)=O(\log k)$.

Is it legitimate to write $g(k,n)=O(n^{O(\log k)})$?

REPLY [2 votes]: No (if you mean what I think you mean by that statement).  If you have more than one variable in play it's always a good idea to keep track of which variables the implied constant for each big-O depends on.  In your example, the implied constant for the outer big-O depends on $k$, but the implied constant for the inner big-O doesn't, so it seems misleading to use notation which pretends they are the same.  And if the implied constant grows fast enough, the final statement you want is false (if an unadormed big-O means it doesn't depend on any of the variables which appear on the LHS).  Consider, as I said in my comment to Yuval Filmus, $g(k, n) = 2^k n^{\log k}, f(k) = \log k$.  In addition to $f(k) = O(\log k)$ you need to know that the implied constant doesn't depend on $n$.
Edit:  The above was nonsense.  Actually you are fine.  You have a constant $C_1$ such that $f(k) \le C_1 \log k$ and another constant $C_2$ such that $g(k) \le C_2 n^{f(k)}$, hence $g(k) \le C_2 n^{C_1 \log k}$, or as Yuval Filmus points out, $g(k) = n^{O(\log k)}$.