3
$\begingroup$

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

$\endgroup$

1 Answer 1

5
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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