# Continued Fractions as an operator.

In dealing with continued fractions in LaTeX, I've become less and less enamored of the \cfrac construct. Especially in my case where I deal with complicated numerators and denominators, listing a few terms can get unwieldy.

I encountered a nice notation for CFs in Lorentzen and Waadeland's "Continued Fractions with Applications" that seemed to be adaptable to my needs. I have no digital copy of the book, so I offer Wolfram's approximation on how this operator is rendered:

(the only difference is that the b terms come before the a terms, and they are separated by a backslash (this is why I asked this question, so I now know how to render the operands and the delimiters properly))

My question now, then, is how can I construct a "continued fraction operator" that acts like \sum and \product? Somehow, trying to use a large letter K and then putting the limits as over- and underscripts has been a bit of a mixed bag (and of course, if the operands themselves are fractions, I have to manually tweak the size of the "K" again!). Might there be a more elegant approach to this?

• Wikipedia says the notation is due to Gauss. Despite its distinguished origin, I don't like it: I have to consciously resist cancelling the fraction. Better to add some sign to the fraction, say a trailing vertical slash on the denominator, to indicate this isn't a real fraction. Aug 24, 2010 at 10:01
• That's actually why I substitute a backslash for a slash in my set of notes, and then place b before a; at least for me it reinforces psychologically that this is not your "typical" fraction. I'm of course not entirely sure that my modification will catch on, but what can you do... :)
– user914
Aug 24, 2010 at 12:36

I'd define a new operator:

\newcommand{\K}{\operatornamewithlimits{K}}


You can then do the following:

Math-mode example:
$\K_{k=0}^\infty \frac{a_k}{b_k}$
or inline $\K_k \frac{a_k}{b_k}$.


And get:

(Note that you must \usepackage{amsmath}.)

• The documentation for amsmath says \operatorname* gives this behavior but doesn't mention \operatornamewithlimits at all. Is this an undocumented synonym? Aug 24, 2010 at 17:26
• You know, I'm not sure where I picked up this trick. I use it for argmax and argmin. Aug 24, 2010 at 20:45
• Egh, I guess I was unclear! I said the notation at Wolfram was just an approximation! (What I was trying to do looks something like K(b\a) with the appropriate over- and underscripts.) I think I can use this, however. Thanks!
– user914
Aug 24, 2010 at 22:07

Using

\newcommand{\bigk}{\mathop{\raisebox{-5pt}{\huge K}}}


gives a fairly good result. Your example would be:

$\bigk_{k=0}^\infty \frac{a_k}{b_k}$

• To use your \bigk, the notation I would actually be using would be something like $\bigk_{k=0}^\infty \bigl (b_k \bigm\backslash a_k \bigr )$ ; would this scale properly if, say, I replace the a_k and b_k with a \frac construct?
– user914
Aug 23, 2010 at 6:17
• @J. Mangaldan: Do \sum and \product scale automatically? I don't see that they do? Aug 23, 2010 at 6:30
• I would use \vcenter{\hbox{...}} rather than \raisebox{-5pt}{...} Aug 23, 2010 at 6:31
• Lev: Odd... I tried it out: latex.codecogs.com/gif.latex?\sum_{j=0}^{\infty}\frac{\frac{\ln(j+1)}{j!}}{\binom{n}{j}} just now... I suppose my memory was mistaken. So using that construct would make the K act like \sum, \product, and \int?
– user914
Aug 23, 2010 at 6:39