Message from discussion
HoldForm and Sum
Path: g2news2.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!newspump.sol.net!post2.nntp.sol.net!posts.news.twtelecom.net!nnrp2.twtelecom.net!not-for-mail
From: "Tong Shiu-sing" <sst...@phy.cuhk.edu.hk>
Newsgroups: comp.soft-sys.math.mathematica
Subject: Re: HoldForm and Sum
Date: Mon, 3 Oct 2011 08:20:21 +0000 (UTC)
Organization: Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Sender: st...@smc.vnet.net
Approved: Steven M. Christensen <st...@smc.vnet.net>, Moderator
Message-ID: <j6br85$8gc$1@smc.vnet.net>
References: <201110010707.DAA17769@smc.vnet.net>
Lines: 58
NNTP-Posting-Date: 03 Oct 2011 07:23:38 GMT
NNTP-Posting-Host: da5e664a.news.twtelecom.net
X-Trace: DXC=7AO]1Z3Kd9T;j@l>C:Hoo^C_A=>8kQj6]m^eQlV`f18WSNHYe;0_B=UEFiONJ7[GoV4]IH3ieW\[R
X-Complaints-To: abuse@twtelecom.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" <dimmec...@yahoo.com>
To: <mathgr...@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.
>
>