Re: Help on Collecting Integers
- To: mathgroup at smc.vnet.net
- Subject: [mg91685] Re: Help on Collecting Integers
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 5 Sep 2008 07:13:13 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <g9qi9p$49e$1@smc.vnet.net>
sergio_r at mail.com wrote:
> (*****
> After an iterative process, I am obtaining the following expression
>
> a0 + b0
> ------- + c0
> a0 + b0 a0 + b0 2
> ------- + c0 ------- + ------------
> 2 2 2
> ------------ + ----------------------
> 2 2
> Out[69]= -------------------------------------
> 2
> or in its InputForm:
> *********)
>
> b[4]=(((a0 + b0)/2 + c0)/2 + ((a0 + b0)/2 + ((a0 + b0)/2 + c0)/2)/
> 2)/2
>
> (****
> In order to analyze the fractional sequence of the symbols a0, b0, and
> c0 (for instance to see if the iterative process leads to a convergent
> sum), I am wondering if I could use Mathematica to
> Collect the terms corresponding to a0, b0, and c0 in the
> form (I did this by hand from the previous expression):
>
> 1 1 1 1 1 1 1 1
> a0 (- + - + --) + b0 (- + - + --) + c0 (- + -)
> 8 8 16 8 8 16 4 8
>
> ****)
You could apply HoldForm[] to the numbers within the expression before
using Collect[]. The resulting expression may need more tweaking to get
the exact form you want, though.
In[1]:= b[4] = (((a0 + b0)/2 + c0)/2 + ((a0 + b0)/2 + ((a0 + b0)/2 +
c0)/2)/2)/2
Out[1]=
1 1 a0 + b0 1 a0 + b0 1 a0 + b0
- (- (------- + c0) + - (------- + - (------- + c0)))
2 2 2 2 2 2 2
In[4]:= expr = b[4] /. x_?NumberQ -> HoldForm[x]
Out[4]=
1 1 1 1 1 1 1
- (- (c0 + (a0 + b0) -) + - ((a0 + b0) - + - (c0 + (a0 + b0) -)))
2 2 2 2 2 2 2
In[5]:= Collect[expr, {a0, b0, c0}]
Out[5]=
1 1 1 2 1 1 2 1 3 1 1 2 1 3
c0 - (- + (-) ) + a0 - (2 (-) + (-) ) + b0 - (2 (-) + (-) )
2 2 2 2 2 2 2 2 2
In[6]:= % // ReleaseHold
Out[6]=
5 a0 5 b0 3 c0
---- + ---- + ----
16 16 8
Regards,
-- Jean-Marc