Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #5313 > unrolled thread

HoldForm and Sum

Started bydimitris <dimmechan@yahoo.com>
First post2011-10-01 07:08 +0000
Last post2011-10-02 06:38 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  HoldForm and Sum dimitris <dimmechan@yahoo.com> - 2011-10-01 07:08 +0000
    Re: HoldForm and Sum Alan <alan.isaac@gmail.com> - 2011-10-02 06:36 +0000
    Re: HoldForm and Sum "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-02 06:36 +0000
    Re: HoldForm and Sum Alan <alan.isaac@gmail.com> - 2011-10-02 06:38 +0000

#5313 — HoldForm and Sum

Fromdimitris <dimmechan@yahoo.com>
Date2011-10-01 07:08 +0000
SubjectHoldForm and Sum
Message-ID<j66e8v$hbs$1@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.

[toc] | [next] | [standalone]


#5315

FromAlan <alan.isaac@gmail.com>
Date2011-10-02 06:36 +0000
Message-ID<j690pd$rbj$1@smc.vnet.net>
In reply to#5313
You can get the terms you want as
Sum[(HoldForm[#1] &)[(-1)^Quotient[i - 1, 3]/i], {i, 1, 12}]

I don't know how to keep them in the order you want.

Alan Isaac

[toc] | [prev] | [next] | [standalone]


#5316

From"Dr. Wolfgang Hintze" <weh@snafu.de>
Date2011-10-02 06:36 +0000
Message-ID<j690qb$rc7$1@smc.vnet.net>
In reply to#5313
"dimitris" <dimmechan@yahoo.com> schrieb im Newsbeitrag 
news:j66e8v$hbs$1@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

[toc] | [prev] | [next] | [standalone]


#5318

FromAlan <alan.isaac@gmail.com>
Date2011-10-02 06:38 +0000
Message-ID<j690s9$rco$1@smc.vnet.net>
In reply to#5313
Sum[(HoldForm[#1] &)[(-1)^Quotient[i - 1, 3]/i], {i, 1, 12}]

I don't know how to maintain the order in the output ...

Alan Isaac

PS Is anyone else finding that posting in the web interface is unreliable?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web