Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

For pedantic reasons I want to display an infinite sum of fractions in fractional form (i.e. as 1/x not as x^(-1)) with an ellipsis at the end of the expression. I have tried a number of ways and none seem to give me what I want. For example

HoldForm[1/#^s] & /@ Table[3^n, {n, 1, 4}]
{1, %, \[Ellipsis]} // Flatten
(Plus @@ %) // TraditionalForm

gives me output ordered as: fractional forms + ... + 1, while StandardForm gave me 1 + ... + the fractional forms. Other ways I tried led to similar forms - none of them yield the book form of 1 + fractions + ... that I want.

I am probably missing something simple here - Thank you for any help

share|improve this question
add comment

1 Answer 1

One way to display the sum in the order you want is to use Row:

HoldForm[1/#^s] & /@ Table[3^n, {n, 1, 4}]
{1, %, ...} // Flatten
Row[%, "+"] // TraditionalForm

$1+\frac{1}{3^s}+\frac{1}{9^s}+\frac{1}{27^s}+\frac{1} {81^s}+\ldots$

The reason why the order isn't maintained in the original version is that Plus has attribute Orderless which means that the order is arbitrary and will by default be determined "lexicographically".

Edit

If you prefer to get the display in HoldForm (which you were already using), another alternative is this:

HoldForm[1/#^s] & /@ Table[3^n, {n, 1, 4}]
{1, %, ...} // Flatten
TraditionalForm[% /. List[x__] :> HoldForm[Plus[x]]]

Here I use a replacement rule to change the List to Plus while leaving it inside HoldForm so that there is no evaluation and re-ordering.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.