Re: Substitution!!!
- To: mathgroup at smc.vnet.net
- Subject: [mg35717] Re: Substitution!!!
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Sat, 27 Jul 2002 06:43:21 -0400 (EDT)
- References: <ahlhov$s7t$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Previous responses have observed that getting the order of the rules correct is the key to a solution. This is clearly the right way for this problem. However I wondered what one might do in general. Here is a slower solution that uses Replace. fcts=(1+x) (1+x+x^2)(1+x+x^3) (1+x+x^6)*(1+x^3+x^6)*(1+x+x^2+x^4+x^6)*(1+x+ x^3+x^4+x^6)*(1+x+x^2+x^5+x^6); rls=Thread[{1+x,1+x+x^2,1+x+x^3,1+x^2+x^3,1+x+x^6,1+x^3+x^6,1+x+x^2+x^4+x^6, 1+x+x^3+x^4+x^6,1+x^5+x^6,1+x+x^2+x^5+x^6,1+x^2+x^3+x^5+x^6, 1+x+x^4+x^5+x^6,1+x^2+x^4+x^5+x^6}\[Rule]{S01,S02,S03,S04,S05,S06, S07,S08,S09,S10,S11,S12,S13}]; Provided that there are two or more factors: rp1[p_,rls_]:=Replace[ p,rls,{1}] rp1[fcts, rls] S01 S02 S03 S05 S06 S07 S08 S10 If there may be only one factor: rp2[p_,rls_]:=Module[{a},{Replace[a p,rls,{1}],a=1}[[1]]] rp2[fcts, rls] S01 S02 S03 S05 S06 S07 S08 S10 -- Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 "Chekad Sarami" <csarami at mtu.edu> wrote in message news:ahlhov$s7t$1 at smc.vnet.net... > Hi, > > > I have a question regarding substitute of an expression with index > variables..I need to make a table for some products of irreducible > polynomials (Irreducible factors of x^63 -1) . But they are so large and I > can't fit them into the columns of my table. So I need to use these > substitutions > > {S_1, S_2, S_3, S_4, S_5, S_6, S_7, S_8, S_9, S_10, S_11, S_12, S_13, S_14} > : ------> {1 + x, 1 + x + x^2, 1 + x + x^3, 1 + x^2 + x^3, 1 + x + x^6, > 1 + x^3 + x^6, 1 + x + x^2 + x^4 + x^6, 1 + x + x^3 + x^4 + x^6, 1 + > x^5 + x^6, 1 + x + x^2 + x^5 + x^6, 1 + x^2 + x^3 + x^5 + x^6, 1 + x + x^4 > + x^5 + x^6, 1 + x^2 + x^4 + x^5 + x^6} > > > > ***** The right side is a list of irreducible polynomials which is assigned > to {S_1, S_2,.... S_14}.******* > > > > For example instead of putting this large expression (1 + x) (1 + x + x^2) > (1 + x + x^3) (1 + x + x^6) (1 + x^3 + x^6) (1 + x + x^2 + x^4 + x\^6) (1 + > x + x^3 + x^4 + x^6) (1 + x + x^2 + x^5 + x^6) in my table I can write it in > tems of S_i's in this form S_1 S_2 S_3 S_4 S_5 S_6 S_7 S_8. > > > > I tried ReplaceAll but it changes i.e. the above example to S_1 (S_1+x^3) > (S_1+x_6) .... Which is not what I want. > > Can anybody tell me how to do this. > > > > > > Regards > > CHEKAD > > > >