Re: pretty output with HoldForm
- To: mathgroup at smc.vnet.net
- Subject: [mg70483] Re: pretty output with HoldForm
- From: dimmechan at yahoo.com
- Date: Tue, 17 Oct 2006 02:59:31 -0400 (EDT)
- References: <egva7f$rgs$1@smc.vnet.net>
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