Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You're pretty close! The problem as you've noted is that "s_i" merely "s_i"; there's no rule that says that the parts of (would-be) variable names after underscores get interpolated in this way.

Here's how I'd do it, assuming I've understood you correctly:

sage: # first make a list of the variables
sage: n = 3
sage: s = list(var('s_%d' % i) for i in range(2*n))
sage: w = list(var('w_%d' % i) for i in range(2*n))
sage: s
[s_0, s_1, s_2, s_3, s_4, s_5]
sage: w
[w_0, w_1, w_2, w_3, w_4, w_5]
sage: 
sage: # then make a list of equqtions
sage: eqs = list(w[k] == s[2*n-k-1] for k in range(2*n))
sage: eqs
[w_0 == s_5, w_1 == s_4, w_2 == s_3, w_3 == s_2, w_4 == s_1, w_5 == s_0]

Note that I had to put a -1 in there to get the relations I think you were aiming at. If I've misunderstood it's easy to change.

You're pretty close! The problem as you've noted is that "s_i" merely "s_i"; there's no rule that says that the parts of (would-be) variable names after underscores get interpolated in this way.

Here's how I'd do it, assuming I've understood you correctly:

sage: # first make a list of the variables
sage: n = 3
sage: s = list(var('s_%d' % i) for i in range(2*n))
sage: w = list(var('w_%d' % i) for i in range(2*n))
sage: s
[s_0, s_1, s_2, s_3, s_4, s_5]
sage: w
[w_0, w_1, w_2, w_3, w_4, w_5]
sage: 
sage: # then make a list of equqtions
equations
sage: eqs = list(w[k] == s[2*n-k-1] for k in range(2*n))
sage: eqs
[w_0 == s_5, w_1 == s_4, w_2 == s_3, w_3 == s_2, w_4 == s_1, w_5 == s_0]

Note that I had to put a -1 in there to get the relations I think you were aiming at. If I've misunderstood it's easy to change.