Displaying Continued Fractions and Nested Surds "properly"

Hi. I’m new to Mathematica, so apologies for the newbie question.

How do I get Mathematica to display continued fractions or nested surds the way you normally would see them?

Nest[1 + 1/# &, "...", 7]

Nest[1 + Sqrt[#] &, "...", 10]

Both end up showing the "+1"s on the “wrong” side of the result. That is, normally when you see these sorts of equations, they start with "1 + " and then have the rest of the nested formula.

I’m teaching a class on the Fibonacci Sequence and Golden Ratio, and would like them to display the way students will most often see them.

These seem to format the way you are wishing. Here is a screenshot of the notebook:

I do note however that the TexForm of, say,

Nest[1 + 1/# &, "...", 7] // TeXForm

gives this

\frac{1}{\frac{1}{\frac{1}{\frac{1}{\frac{1}{\frac{1}{\frac{1}{\text{...}}+1}+1}+1}+1}+1}
   +1}+1

which formats (at least in this forum’s TeX typsetting) as

$\frac{1}{\frac{1}{\frac{1}{\frac{1}{\frac{1}{\frac{1}{\frac{1}{\text{…}}+1}+1}+1}+1}+1}
+1}+1$

Is this the issue that you are referring to? The Mathematica native typesetting seems to be fine. The TeX seems to be the opposite of what’s desired.

Odd. I wonder if it might be version dependant? I have Mathematica 10.0.0.0. Here’s what I see with output cells set to TraditionalForm in my preferences. Also TeXForm is just like yours.


If I type

Nest[1 + Sqrt[#] &, "...", 10] // TreeForm

and hover over the topmost node, interestingly the tooltip shows it the way you would expect.


Any suggestions how to get it to behave the way I’d like? Thanks!

My cells are in Standard Form. If I change them to TraditionalForm then they have the opposite behavior that you are noticing. That also explains the TeXForm result–presumably, and sensibly, the TEeXForm of an expression is based on the TraditionalForm version.

I only very rarely use TraditionalForm as a formatting choice for Mathematica expressions…

Thanks. That’s what the problem is. I like the look of TraditionalForm more for many things, which is why I set it to be the default. Perhaps this should be considered a bug in TraditionalForm? Traditionally no one would write them the backwards way, after all!