Question: Is it possible to Add/sum by mapping multiple values from a list

I want to sum a series by getting multiple values from a list.  Based on the list L I was trying

add(A, [m2, m3] in L)   This seem to have dissapeared from the document but the error message remains.

restart

``

NULL

NULL

A := factorial(2*m2+3*m3)*c0^(1+m2+2*m3)*c2^m2*c3^m3/(factorial(1+m2+2*m3)*factorial(m2)*factorial(m3)*c1^(2*m2+3*m3+1))

factorial(2*m2+3*m3)*c0^(1+m2+2*m3)*c2^m2*c3^m3/(factorial(1+m2+2*m3)*factorial(m2)*factorial(m3)*c1^(2*m2+3*m3+1))

(1)

"P:=3, N:=4"

4

(2)

``

I found this code by Kitonum 16740  https://www.mapleprimes.com/questions/138955-How-Do-I-Create-A-Variable-Number-Of-Nested-Loops-

S := {seq(0 .. N)}; l := P-1; f := proc (T) options operator, arrow; [seq(seq([op(T[j]), S[i]], i = 1 .. nops(S)), j = 1 .. nops(T))] end proc; L := (f@@l)([[]])

[[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4]]

(3)

nops(L)

25

(4)

NULLNULL

``

nops(L)

25

(5)

Instead of using add(add(A, m2 = 0 .. 4)*m3 = 0 .. 4)I would like to map m2 and m3 to the values in list L and sum them. This should give a method for having a variable number of loops

I tried variants off without success

 

add(A, `in`([m2, m3], L))

Error, illegal use of an object as a name

 

 

 

 

 

for the next higher order would need to map m2,m3, m4 to the generated list.

 

 

 

B := factorial(2*m2+3*m3+4*m4)*c0^(1+m2+2*m3+3*m4)*c2^m2*c3^m3*c4^m4/(factorial(1+m2+2*m3+3*m4)*factorial(m2)*factorial(m3)*factorial(m4)*c1^(2*m2+3*m3+4*m4+1))

factorial(2*m2+3*m3+4*m4)*c0^(1+m2+2*m3+3*m4)*c2^m2*c3^m3*c4^m4/(factorial(1+m2+2*m3+3*m4)*factorial(m2)*factorial(m3)*factorial(m4)*c1^(2*m2+3*m3+4*m4+1))

(6)

P := 4; S := {seq(0 .. N)}; l := P-1; f := proc (T) options operator, arrow; [seq(seq([op(T[j]), S[i]], i = 1 .. nops(S)), j = 1 .. nops(T))] end proc; L := (f@@l)([[]])

[[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3], [0, 0, 4], [0, 1, 0], [0, 1, 1], [0, 1, 2], [0, 1, 3], [0, 1, 4], [0, 2, 0], [0, 2, 1], [0, 2, 2], [0, 2, 3], [0, 2, 4], [0, 3, 0], [0, 3, 1], [0, 3, 2], [0, 3, 3], [0, 3, 4], [0, 4, 0], [0, 4, 1], [0, 4, 2], [0, 4, 3], [0, 4, 4], [1, 0, 0], [1, 0, 1], [1, 0, 2], [1, 0, 3], [1, 0, 4], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 1, 3], [1, 1, 4], [1, 2, 0], [1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 3, 0], [1, 3, 1], [1, 3, 2], [1, 3, 3], [1, 3, 4], [1, 4, 0], [1, 4, 1], [1, 4, 2], [1, 4, 3], [1, 4, 4], [2, 0, 0], [2, 0, 1], [2, 0, 2], [2, 0, 3], [2, 0, 4], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 1, 3], [2, 1, 4], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2, 2, 3], [2, 2, 4], [2, 3, 0], [2, 3, 1], [2, 3, 2], [2, 3, 3], [2, 3, 4], [2, 4, 0], [2, 4, 1], [2, 4, 2], [2, 4, 3], [2, 4, 4], [3, 0, 0], [3, 0, 1], [3, 0, 2], [3, 0, 3], [3, 0, 4], [3, 1, 0], [3, 1, 1], [3, 1, 2], [3, 1, 3], [3, 1, 4], [3, 2, 0], [3, 2, 1], [3, 2, 2], [3, 2, 3], [3, 2, 4], [3, 3, 0], [3, 3, 1], [3, 3, 2], [3, 3, 3], [3, 3, 4], [3, 4, 0], [3, 4, 1], [3, 4, 2], [3, 4, 3], [3, 4, 4], [4, 0, 0], [4, 0, 1], [4, 0, 2], [4, 0, 3], [4, 0, 4], [4, 1, 0], [4, 1, 1], [4, 1, 2], [4, 1, 3], [4, 1, 4], [4, 2, 0], [4, 2, 1], [4, 2, 2], [4, 2, 3], [4, 2, 4], [4, 3, 0], [4, 3, 1], [4, 3, 2], [4, 3, 3], [4, 3, 4], [4, 4, 0], [4, 4, 1], [4, 4, 2], [4, 4, 3], [4, 4, 4]]

(7)

nops(L)

125

(8)

NULL


 

Download Sum_by_mapping_to_a_list_question.mw

Please Wait...