MathGroup Archive 2006

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

Search the Archive

Re: pretty output with HoldForm


One method is to use the defined function EvaluateAt, which you can
find it in the
Further Examples of ReplacePart at the Help Browser or at

http://documents.wolfram.com/mathematica/Built-inFunctions/ListsAndMatrices/ListOperations/FurtherExamples/ReplacePart.html

See also

http://www.verbeia.com/mathematica/tips/HTMLLinks/Tricks_Misc_1.html
http://library.wolfram.com/infocenter/MathSource/495/

In what follows everything is in InputForm

Here is the definition of EvaluateAt

EvaluateAt[expr_, positions_] := Fold[ReplacePart[#1, #1[[Sequence @@
#2]], #2] & ,
expr, positions]

Here is your function, as a pure function

f = HoldForm[1/(2*#1 + 1) - 1/(4*#1 + 2) - 1/(4*#1 + 4)] & ;

Here is the sum

Sum[f[i], {i, 1, 5}]
HoldForm[1/(2*1 + 1) - 1/(4*1 + 2) - 1/(4*1 + 4)] + HoldForm[1/(2*2 +
1) - 1/(4*2 + 2) -
1/(4*2 + 4)] + HoldForm[1/(2*3 + 1) - 1/(4*3 + 2) - 1/(4*3 + 4)] +
HoldForm[1/(2*4 + 1) -
 1/(4*4 + 2) - 1/(4*4 + 4)] + HoldForm[1/(2*5 + 1) - 1/(4*5 + 2) -
1/(4*5 + 4)]

And here is the sum in the desired format

EvaluateAt[%, Position[%, _Times]]
HoldForm[1/3 - 1/6 - 1/8] + HoldForm[1/5 - 1/10 - 1/12] + HoldForm[1/7
- 1/14 - 1/16] + HoldForm[1/9 - 1/18 - 1/20] +  HoldForm[1/11 - 1/22 -
1/24]

Regards
Dimitris


  • Prev by Date: Re: pretty output with HoldForm
  • Next by Date: Re: Re: Demostration
  • Previous by thread: Re: pretty output with HoldForm
  • Next by thread: How to make an inline cell (inside a Text cell) to be a centered equation?