Question: Problem with sum in linked functions

I am trying to define a sum which is obtained from linked functions (which also contain the sum command). 

The problem is: if I modify the first function p and rerun the worksheet (except fot the restart command), then the changes do not affect the result. Does anyone know why? Thank you very much.
 

I start with this

restart

p := proc (i, j) options operator, arrow; sum('cat(A, _, i, j, k)', 'k' = 1 .. 3) end proc

proc (i, j) options operator, arrow; sum('cat(A, _, i, j, k)', 'k' = 1 .. 3) end proc

(1)

q := proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

(2)

r := sum('q(i)', 'i' = 1 .. 3)

A_331+A_332+A_333+A_321+A_322+A_323+A_311+A_312+A_313+A_231+A_232+A_233+A_221+A_222+A_223+A_211+A_212+A_213+A_133+A_123+A_131+A_132+A_121+A_122+A_111+A_112+A_113

(3)

If I modify p (I make it twice its initial value), then this does not affect the value of q and r

p := proc (i, j) options operator, arrow; 2*(sum('cat(A, _, i, j, k)', 'k' = 1 .. 3)) end proc

proc (i, j) options operator, arrow; 2*(sum('cat(A, _, i, j, k)', 'k' = 1 .. 3)) end proc

(4)

q := proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

(5)

r := sum('q(i)', 'i' = 1 .. 3)

A_331+A_332+A_333+A_321+A_322+A_323+A_311+A_312+A_313+A_231+A_232+A_233+A_221+A_222+A_223+A_211+A_212+A_213+A_133+A_123+A_131+A_132+A_121+A_122+A_111+A_112+A_113

(6)

Why?
Even if I  unassign p, q and r, this does not work, either.

unassign('p', 'q', 'r')

p := proc (i, j) options operator, arrow; 2*(sum('cat(A, _, i, j, k)', 'k' = 1 .. 3)) end proc

proc (i, j) options operator, arrow; 2*(sum('cat(A, _, i, j, k)', 'k' = 1 .. 3)) end proc

(7)

q := proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

(8)

r := sum('q(i)', 'i' = 1 .. 3)

A_331+A_332+A_333+A_321+A_322+A_323+A_311+A_312+A_313+A_231+A_232+A_233+A_221+A_222+A_223+A_211+A_212+A_213+A_133+A_123+A_131+A_132+A_121+A_122+A_111+A_112+A_113

(9)

Only if I restart, then I can modify p and change the rest of values

restart

p := proc (i, j) options operator, arrow; 2*(sum('cat(A, _, i, j, k)', 'k' = 1 .. 3)) end proc

proc (i, j) options operator, arrow; 2*(sum('cat(A, _, i, j, k)', 'k' = 1 .. 3)) end proc

(10)

q := proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

proc (i) options operator, arrow; sum('p(i, j)', 'j' = 1 .. 3) end proc

(11)

r := sum('q(i)', 'i' = 1 .. 3)

2*A_332+2*A_333+2*A_323+2*A_331+2*A_313+2*A_321+2*A_322+2*A_311+2*A_312+2*A_231+2*A_232+2*A_233+2*A_221+2*A_222+2*A_223+2*A_212+2*A_213+2*A_211+2*A_131+2*A_132+2*A_133+2*A_121+2*A_122+2*A_123+2*A_111+2*A_112+2*A_113

(12)

``

``


 

Download problem_with_sums.mw

Please Wait...