Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5333 > unrolled thread
| Started by | "Tong Shiu-sing" <sstong@phy.cuhk.edu.hk> |
|---|---|
| First post | 2011-10-03 08:20 +0000 |
| Last post | 2011-10-03 08:20 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: HoldForm and Sum "Tong Shiu-sing" <sstong@phy.cuhk.edu.hk> - 2011-10-03 08:20 +0000
| From | "Tong Shiu-sing" <sstong@phy.cuhk.edu.hk> |
|---|---|
| Date | 2011-10-03 08:20 +0000 |
| Subject | Re: HoldForm and Sum |
| Message-ID | <j6br85$8gc$1@smc.vnet.net> |
Hello,
You can change the attributes of Plus to achieve the forms:
Unprotect[Plus]
ClearAttributes[Plus, Orderless]
Sum[(HoldForm[#1] &)[1/i], {i, 1, 10}]
gives
1+1/2+1/3...+1/8+1/9+1/10
Sum[((-1)^Quotient[i - 1, 3] HoldForm[#1] &)[1/i], {i, 1, 12}]
gives
1+1/2+1/3-1/4-1/5-1/6+1/7+1/8+1/9-1/10-1/11-1/12
Hope this is useful.
Regards,
Dominic
----- Original Message -----
From: "dimitris" <dimmechan@yahoo.com>
To: <mathgroup@smc.vnet.net>
Sent: Saturday, October 01, 2011 3:07 PM
Subject: HoldForm and Sum
> Hell to all.
>
> A (well-known) nice example of the use of HoldForm is:
>
> Sum[(HoldForm[#1] & )[i], {i, 1, 10}]
>
> (*output omited*)
>
> I want to do the same with 1/i
>
> Sum[(HoldForm[#1] & )[1/i], {i, 1, 10}]
>
> Mathematica output is
>
> 1/10+1/9+1/8+...+1/3+1/2+1
>
> My first question is how can I get the output in the form
>
> 1+1/2+1/3...+1/8+1/9+1/10
>
>
> My second query comes now. How can I combine HoldForm and Sum (or
> anything else) in order to have the following output (unevaluated)?
>
> 1+1/2+1/3-1/4-1/5-1/6+1/7+1/8+1/9-1/10-1/11-1/12
>
> that is, three positive terms after three negative and so on.
>
> Thank you in advance for your response.
>
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web