Re: Simplify needs ages to finish

• To: mathgroup at smc.vnet.net
• Subject: [mg44767] Re: Simplify needs ages to finish
• From: Roland Franzius <roland.franzius at uos.de>
• Date: Tue, 25 Nov 2003 00:45:36 -0500 (EST)
• Organization: Universitaet Hannover
• References: <bpn2r5$lhj$1@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

Thomas Gutzler wrote:

1) At least three syntax errors are in this text. Look for & & instead &&

2) Rewrite your SetDelayed in the following form
o1[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
Evaluate[LogicalExpand[righthandside]]

This will save you some time but only if:

3) you state the definitions in reverse order. Otherwise you are getting
lost alredy at definition time.

4) write a test set

test=
Rule@@@Transpose[{{a1,a1,...b4},Table[If[Random[]<0.5,True,False],{8}]}]

and test your definitions using values  Replace[#,test]&/@op[a1..]

5) You need at least 256 MB memory. Otherwise disk swapping becomes time
consuming

6)dont print the full result. (I have not seen it;-) Probably it will
take 100 times the memory used to represent the result internally.

7) Try
Xor[1 && 2 || 3 && 4, 5 && 6 || 7 && 8, 9 && 10 || 11 && 12] //
LogicalExpand
to see the explosion of logical combinations. Try to write the result
using Partition.

The complexity is seen by considering the value table: 2^8 =256 possible
input values for a1..b4 \in{True,False}. It will be easier to calculate
this table using all possible values of True,False instead of symbolic
expressions.

--

Roland Franzius

> Hi,
>
> I've got the following simple (well, IMO) boolean equations and can't
> believe that it takes more than 2 hours on an Intel(R) Xeon(TM) CPU
> 2.00GHz to evaluate the last output: foo[a1, a2, a3, a4, b1, b2, b3, b4]
> I'm using mathematica 4.1.
>
> Am I doing something wrong?
>
> cheers,
>   Tom
>
> Here comes the code:
>
> o1[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
>   (a4 && b1 && b2 && b3 && b4) || (a1 && a4 && b2 && b3 && b4) ||
>   (a2 && a4 && b1 && b3 && b4) || (a1 && a2 && a4 && b3 && b4) ||
>   (a3 && a4 && b1 && b2 && b4) || (a1 && a3 && a4 && b2 && b4) ||
>   (a2 && a3 && a4 && b1 && b4) || (a1 && a2 && a3 && a4 && b4) ||
>   (a3 && b1 && b2 && b3) || (a1 && a3 && b2 && b3) ||
>   (a2 && a3 && b1 && b3) || (a1 && a2 && a3 && b3) ||
>   (a2 && b1 && b2) || (a1 && a2 && b2) || (a1 & & b1);
>
> o2[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
>   (a1 && !a4 && !b1 && !b2 && !b3) || (!a1 && !a4 && b1 && !b2 && !b3) ||
>   (a1 && !a2 && !a4 && !b1 && !b3) || (!a1 && !a2 && !a4 && b1 && !b3) ||
>   (a1 && !a3 && !a4 && !b1 && !b2) || (!a1 && !a3 && !a4 && b1 && !b2) ||
>   (a1 && !a2 && !a3 && !a4 && !b1) || (!a1 && !a2 && !a3 && !a4 && b1) ||
>   (a1 && !b1 && !b2 && !b3 && !b4) || (!a1 && b1 && !b2 && !b3 && !b4) ||
>   (a1 && !a2 && !b1 && !b3 && !b4) || (!a1 && !a2 && b1 && !b3 && !b4) ||
>   (a1 && !a3 && !b1 && !b2 && !b4) || (!a1 && !a3 && b1 && !b2 && !b4) ||
>   (a1 && !a2 && !a3 && !b1 && !b4) || (!a1 && !a2 & &!a3 && b1 && !b4) ||
>   (!a1 && a4 && !b1 && b2 && b3 && b4) ||
>   (!a1 && a2 && a4 && !b1 && b3 && b4) ||
>   (!a1 && a3 && a4 && !b1 && b2 && b4) ||
>   (!a1 && a2 && a3 && a4 && !b1 && b4) ||
>   (a1 && a4 && b1 && b2 && b3 && b4) ||
>   (a1 && a2 && a4 && b1 && b3 && b4) ||
>   (a1 && a3 && a4 && b1 && b2 && b4) ||
>   (a1 && a2 && a3 && a4 && b1 && b4) ||
>   (a1 && !a3 && !b1 && !b2 && !b3) || (!a1 && !a3 && b1 && !b2 && !b3) ||
>   (a1 && !a2 && !a3 && !b1 && !b3) || (!a1 && !a2 && !a3 && b1 && !b3) ||
>   (!a1 && a3 && !b1 && b2 && b3) || (!a1 && a2 && a3 && !b1 && b3) ||
>   (a1 && a3 && b1 && b2 && b3) || (a1 && a2 && a3 && b1 && b3) ||
>   (a1 && !a2 && !b1 && !b2) || (!a1 && !a2 && b1 && !b2) ||
>   (!a1 && a2 && !b1 && b2) || (a1 && a2 && b1 && b2);
>
> o3[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
>   (a2 && !a4 && !b2 && !b3) || (!a2 && !a4 && b2 && !b3) ||
>   (a2 && !a3 && !a4 && !b2) || (!a2 && !a3 && !a4 && b2) ||
>   (a2 && !b2 && !b3 && !b4) || (!a2 && b2 && !b3 && !b4) ||
>   (a2 && !a3 && !b2 && !b4) || (!a2 && !a3 && b2 && !b4) ||
>   (!a2 && a4 && !b2 && b3 & & b4) || (!a2 && a3 && a4 && !b2 && b4) ||
>   (a2 && a4 && b2 && b3 && b4) || (a2 && a3 && a4 && b2 && b4) ||
>   (a2 && !a3 && !b2 && !b3) || (!a2 && !a3 && b2 && !b3) ||
>   (!a2 && a3 && !b2 && b3) || (a2 && a3 && b2 && b3);
>
> o4[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
>   (!a3 && a4 && !b3 && b4) || (a3 && a4 && b3 && b4) ||
>   (a3 && !b3 && !b4) || (!a3 && b3 && !b4) || (a3 && !a4 && !b3) ||
>   (!a3 && !a4 && b3);
>
> o5[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
>   (a4 && !b4) || (!a4 && b4);
>
> oparity[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
>   Xor[o1[a1, a2, a3, a4, b1, b2, b3, b4],
>       o2[a1, a2, a3, a4, b1, b2, b3, b4],
>       o3[a1, a2, a3, a4, b1, b2, b3, b4],
>       o4[a1, a2, a3, a4, b1, b2, b3, b4],
>       o5[a1, a2, a3, a4, b1, b2, b3, b4]];
>
> foo[a1_, a2_, a3_, a4_, b1_, b2_, b3_, b4_] :=
>   Simplify[Xor[oparity[a1, a2, a3, a4, b1, b2, b3, b4],
>               !oparity[!a1, !a2, !a3, !a4, !b1, !b2, !b3, !b4]]];
>
> foo[a1, a2, a3, a4, b1, b2, b3, b4]
>



• Prev by Date: Re: Re: Improper integral
• Next by Date: subscribe and ask questions
• Previous by thread: Simplify needs ages to finish
• Next by thread: Re: Simplify needs ages to finish