Quantcast
Channel: Adding optional argument (as exponent) to custom math expressions - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Adding optional argument (as exponent) to custom math expressions

$
0
0

I want to define a command \bigO where if I type something like \bigO[3]{\epsilon} it gives $\mathcal{O}(\epsilon^3)$, and if I leave out the optional argument and have \bigO{\epsilon} it defaults to $\mathcal{O}(\epsilon)$.

Currently, I have something like this: \newcommand{\bigO}[2][1]{\mathcal{O}(#2^#1)}, which works if I want the default exponent, i.e. 1, to appear explicitly. But what if I don't want 1 to appear in the exponent in the default case?


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>