RE: pretty output with HoldForm
- To: mathgroup at smc.vnet.net
- Subject: [mg70455] RE: [mg70425] pretty output with HoldForm
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 17 Oct 2006 02:58:12 -0400 (EDT)
Peter, Download the free ExpressionManipulation package at my web site and then use the EvaluateAtPattern command. (I didn't know if you wanted to sum from 0 or from 1.) Needs["Algebra`ExpressionManipulation`"] kl[n_] := HoldForm[ 1/(2n + 1) - 1/(4n + 2) - 1/(4n + 4)] Sum[kl[n], {n, 0, 5}] Sum[kl[n], {n, 0, 5}] // EvaluateAtPattern[_Times]; % // EvaluateAtPattern[_Times] HoldForm[1 - 1/2 - 1/4] + HoldForm[1/3 - 1/6 - 1/8] + HoldForm[1/5 - 1/10 - 1/12] + HoldForm[1/7 - 1/14 - 1/16] + HoldForm[1/11 - 1/22 - 1/24] + HoldForm[1/9 - 1/18 - 1/20] (I'm a little disconcerted that I had to apply it twice. The routine is also in Tensorial.) David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Peter Breitfeld [mailto:phbrf at t-online.de] To: mathgroup at smc.vnet.net I want to get the following output for the series: (1 - 1/2 - 1/4) + (1/3 - 1/6 - 1/8) + (1/5 - 1/10 - 1/12) + (1/7 - 1/14 - 1/16) . . . What I did was kl[n_]:=HoldForm[ 1/(2n+1)-1/(4n+2)-1/(4n+4)] then I enter eg: reihe= Sum[kl[n],{n,1,5}] This works quite good, but the fractions are completely unevaluated (because of HoldForm, I know) and display as 1 ---------- 4 2 + 2 But I want them displayed as 1 -- 10 Is there a way to evaluate parts inside a HoldForm, so that the fractions are evaluated but not the sums? Gruss Peter -- ==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-== Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de