       Re: Bernoulli variable algebra

• To: mathgroup at smc.vnet.net
• Subject: [mg46539] Re: Bernoulli variable algebra
• From: Dr Bob <drbob at bigfoot.com>
• Date: Sun, 22 Feb 2004 11:27:42 -0500 (EST)
• References: <8e.40ca9af.2d6971b9@aol.com>
• Sender: owner-wri-mathgroup at wolfram.com

```If the calculations involve any kind of sub-expressions, they can be
expanded individually, as in my simple example. If not, we might simply
"manage" its expansion. Details depend on how the expressions arise, but
here's an example. First I take a single step to reduce a large power.
Then I take the other 96 steps or so. Then I expand a product to finish
the process.

subFunction[a_Symbol] :=
Block[{aa = ToString[a]},
MakeExpression[SubscriptBox[ToString[a],
i_], f_] := MakeExpression[
RowBox[{ToString[a], "[", i, "]"}]];
MakeBoxes[a[i_], f_] := SubscriptBox[
MakeBoxes[a, f], MakeBoxes[i, f]]]
subFunction[binary]
binary[i_]*binary[i_] ^= binary[i];
Unprotect[Power];
binary[i_]^(n_)?Positive := binary[i]
Protect[Power];
stepDown = (a_)^(n_Integer) /; n > 2 && PolynomialQ[a, binary[i_]] :>
Expand[a^2]*a^(n - 2);

(binary[j] + binary[i])^100

(binary[i] + binary[j])^100
% /. stepDown

(binary[i] + binary[j])^98* (binary[i] + binary[j] +
2*binary[i]*binary[j])
% //. stepDown

(binary[i] + binary[j])^2*
(binary[i] + binary[j] +
2*binary[i]*binary[j])*
(binary[i] + binary[j] +
14*binary[i]*binary[j])^2*
(binary[i] + binary[j] +
254*binary[i]*binary[j])*
(binary[i] + binary[j] +
65534*binary[i]*binary[j])*
(binary[i] + binary[j] +
4294967294*binary[i]*
binary[j])^2

Expand[%]
binary[i] + binary[j] +
1267650600228229401496703205374*binary[i]*binary[j]

Bobby

On Sat, 21 Feb 2004 21:45:13 EST, <JMyers6761 at aol.com> wrote:

>
> In a message dated 2/21/04 11:01:57 AM, drbob at bigfoot.com writes:
>
> << Bobby >>
>
> represents an approach I had not considered. However I believe it will
> still require
> the expansion of the inititial expression which for the actual problem I
> have
> is on the order of 10^6 terms - if the expression could be expanded I
> believe
> your approach would produce the correct results but the trick I'm
> looking for
> is a transformation that could be done without the Expand. I know from
> other
> analysis of the problem that the resulting expression, after the
> Bernoulli
> transformation, will still be large, on the order of 10^3 terms, but
> will be
> managable.  I have reposted what I hope is a more complete statement of
> my
> problem. Thanks for the help.
>
> Al

```

• Prev by Date: i dont understand module.
• Next by Date: Re: Bernoulli variable algebra
• Previous by thread: Re: Bernoulli variable algebra
• Next by thread: Re: Bernoulli variable algebra