MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: HoldForm and Sum

  • To: mathgroup at smc.vnet.net
  • Subject: [mg121783] Re: HoldForm and Sum
  • From: "Dr. Wolfgang Hintze" <weh at snafu.de>
  • Date: Sun, 2 Oct 2011 02:35:41 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j66e8v$hbs$1@smc.vnet.net>

"dimitris" <dimmechan at yahoo.com> schrieb im Newsbeitrag 
news:j66e8v$hbs$1 at smc.vnet.net...
> 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.
>
>
These two sums do what you want (except for the "ugly" 1/1)

s1 = Sum[HoldForm[1/#] & [i], {i,1, 10}] (* 1/# rather than [1/i] *)


1   1   1   1   1   1   1   1   1   1
- + - + - + - + - + - + - + - + - + --
1   2   3   4   5   6   7   8   9   10

s2 = Sum[(-1)^Floor[(k-1)/3]HoldForm[1/#]&[k],{k,1,12}]//OutputForm


1   1   1   1   1   1   1   1   1   1    1    1
- + - + - - - - - - - + - + - + - - -- - -- - --
1   2   3   4   5   6   7   8   9   10   11   12

Wolfgang




  • Prev by Date: count zeros in a number
  • Next by Date: Re: Integrating a Piecewise function four times but different results
  • Previous by thread: Re: HoldForm and Sum
  • Next by thread: Re: replace all