Question: Creating a procedure for expression

 

``

restart:

 

C=2;

C = 2

(1)

w[2]*s[1]+w[1]*s[2];

s[1]*w[2]+s[2]*w[1]

(2)

C=3;

C = 3

(3)

(w[3]*s[2]+w[2]*s[3])*s[1];

(s[2]*w[3]+s[3]*w[2])*s[1]

(4)

C=4;

C = 4

(5)

((w[4]*s[3]+w[3]*s[4])*s[2]+w[2]*s[3]*s[4] )*s[1];

((s[3]*w[4]+s[4]*w[3])*s[2]+w[2]*s[3]*s[4])*s[1]

(6)

C=5;

C = 5

(7)

(((w[5]*s[4]+w[4]*s[5])*s[3]+w[3]*s[4]*s[5] )*s[2]+w[2]*s[3]*s[4]*s[5] )*s[1];

(((s[4]*w[5]+s[5]*w[4])*s[3]+w[3]*s[4]*s[5])*s[2]+w[2]*s[3]*s[4]*s[5])*s[1]

(8)

C=6;

C = 6

(9)

((((w[6]*s[5]+s[6]*w[5])*s[4]+w[4]*s[5]*s[6])*s[3]+w[3]*s[4]*s[5]*s[6])*s[2]+w[2]*s[3]*s[4]*s[5]*s[6])*s[1];

((((s[5]*w[6]+s[6]*w[5])*s[4]+s[5]*s[6]*w[4])*s[3]+s[4]*s[5]*s[6]*w[3])*s[2]+s[3]*s[4]*s[5]*s[6]*w[2])*s[1]

(10)

 

``


Download pattern.mw

 

This probably isnt too difficult to write a procedure to generate the expression, given C=2,3,4,5,...

But I may be thinking too much and stuck...

 

Also, I am thinking that if it is possible to use something like a "fibonacci sequence", in the famouse example here, which uses the in a procedure. Probably, we dont need to use this.

 

Thanks,

 

casper

 

Please Wait...