MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Re: Substitution!!!

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35702] RE: [mg35668] Re: [mg35660] Substitution!!!
  • From: "DrBob" <majort at cox-internet.com>
  • Date: Fri, 26 Jul 2002 04:16:59 -0400 (EDT)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Here's a slightly different solution that you may find useful.

expr = {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}; 
sub = Reverse[Thread[expr -> 
      Table[((Remove[#1]; Symbol[#1]) & )
        [StringJoin["S", ToString[i]]], {i, 1, 13}]]]; 
expr /. Sub

Bobby Treat

-----Original Message-----
From: BobHanlon at aol.com [mailto:BobHanlon at aol.com] 
To: mathgroup at smc.vnet.net
Subject: [mg35702] [mg35668] Re: [mg35660] Substitution!!!


In a message dated 7/24/02 4:37:23 AM, csarami at mtu.edu writes:

>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.
>

Reverse the order of the substitutions so that the longer expressions
are 
replaced first

sub=Reverse[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}->
          {S01,S02,S03,S04,S05,S06,S07,S08,
            S09,S10,S11,S12,S13}]];

(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)/.sub

S01 S02 S03 S05 S06 S07 S08 S10


Bob Hanlon
Chantilly, VA  USA





  • Prev by Date: Re: Removing the Context
  • Next by Date: RE: Installing package "SpreadOption`"
  • Previous by thread: Re: Substitution!!!
  • Next by thread: Re: Substitution!!!