- #1
kaizen.moto
- 98
- 0
Dear all,
I have a problem with regard to the summation which is done inside the Do-Loop iteration. I have attached the file which includes further information about the defintions, some examples and etc.
Please help me to get the right codes in order to express totalu1, totalv1, totalu2 and totalv2. Please note that all of these codes to be kept inside the Do-loop.
The code is expressed as follows:
Do[Clear[mat1,mat2,usum1,vsum1,usum2,vsum2,totalmat];mat1={{m+n},{3m+5n}};mat2={{3m+4n},{5m+10n}};usum1[m_,n_]:=mat1[[1,1]];vsum1[m_,n_]:=mat1[[2,1]];usum2[m_,n_]:=mat2[[1,1]];vsum2[m_,n_]:=mat2[[2,1]];totalu1=?;totalv1= ? ;totalu2 = ? ;totalv2 = ? ;totalmat={totalu1,totalv1,totalu2,totalv2};Print["m=",m,",","n=",n,"-->",totalmat],{m,1,5,2},{n,1,5,2}]
mat1 and mat2 are column vectors. m and n are intergers where m = 1,3,5,7,9... and n = 1,3,5,7,9,11,...
totalu1 is the summation of usum1 with respect to ' m' term only and must begins with m = 1 (i.e. n is fixed). For example, usum1[5,3]: totalu1 = usum1[1,3]+ usum1[3,3] + usum11[5,3]
totalv1 is the summation of vsum1 with respect to ' n' term only and must begins with n = 1 (i.e. m is fixed). For example, vsum1[3,3]: totalu1 = usum1[3,1]+ usum1[3,3]
same as above, totalu2 is the summation of usum2 with respect to ' m' term only and must begins with m = 1 (i.e. n is fixed). For example, usum2[1,3]: totalu2 = usum2[1,3] only
same as above, totalv2 is the summation of vsum2 with respect to 'n' term only and must begins with n = 1 (i.e. m is fixed). For example, vsum2[1,3]: totalv2 = vsum2[1,1]+ vsum2[1,3] .
For examples: when m = 1 and n = 5,
totalu1[m, n] or totalu1[1, 5] = usum1[1, 5] = 6
when m = 5 and n = 5,
totalu1[m, n] or totalu1[5, 5] = usum1[1, 5] + usum1[3, 5] + usum1[5, 5] = 6 + 8 + 10 = 24
when m = 3 and n = 5,
totalv1[m, n] or totalv1[3, 5] = vsum1[3, 1] + vsum1[3, 3] + vsum1[3, 5] = 14 + 24 + 34 = 72
when m = 5 and n = 1,
totalu2[m, n] or totalu2[5, 1] = usum2[1, 1] + usum2[3, 1] + usum2[5, 1] = 7 + 13 + 19 = 39
when m = 1 and n = 5,
totalv2[m, n] or totalv2[1, 5] = vsum2[1, 1] + vsum2[1, 3] + vsum2[1, 5] = 15 + 35 + 55 = 105
when m = 5 and n = 1, totalv2[5, 1] = vsum2[5, 1] = 35
Please note that all of these should be done inside the Do-Loop.
Any kind help is much appreciated.
Thank you.
I have a problem with regard to the summation which is done inside the Do-Loop iteration. I have attached the file which includes further information about the defintions, some examples and etc.
Please help me to get the right codes in order to express totalu1, totalv1, totalu2 and totalv2. Please note that all of these codes to be kept inside the Do-loop.
The code is expressed as follows:
Do[Clear[mat1,mat2,usum1,vsum1,usum2,vsum2,totalmat];mat1={{m+n},{3m+5n}};mat2={{3m+4n},{5m+10n}};usum1[m_,n_]:=mat1[[1,1]];vsum1[m_,n_]:=mat1[[2,1]];usum2[m_,n_]:=mat2[[1,1]];vsum2[m_,n_]:=mat2[[2,1]];totalu1=?;totalv1= ? ;totalu2 = ? ;totalv2 = ? ;totalmat={totalu1,totalv1,totalu2,totalv2};Print["m=",m,",","n=",n,"-->",totalmat],{m,1,5,2},{n,1,5,2}]
mat1 and mat2 are column vectors. m and n are intergers where m = 1,3,5,7,9... and n = 1,3,5,7,9,11,...
totalu1 is the summation of usum1 with respect to ' m' term only and must begins with m = 1 (i.e. n is fixed). For example, usum1[5,3]: totalu1 = usum1[1,3]+ usum1[3,3] + usum11[5,3]
totalv1 is the summation of vsum1 with respect to ' n' term only and must begins with n = 1 (i.e. m is fixed). For example, vsum1[3,3]: totalu1 = usum1[3,1]+ usum1[3,3]
same as above, totalu2 is the summation of usum2 with respect to ' m' term only and must begins with m = 1 (i.e. n is fixed). For example, usum2[1,3]: totalu2 = usum2[1,3] only
same as above, totalv2 is the summation of vsum2 with respect to 'n' term only and must begins with n = 1 (i.e. m is fixed). For example, vsum2[1,3]: totalv2 = vsum2[1,1]+ vsum2[1,3] .
For examples: when m = 1 and n = 5,
totalu1[m, n] or totalu1[1, 5] = usum1[1, 5] = 6
when m = 5 and n = 5,
totalu1[m, n] or totalu1[5, 5] = usum1[1, 5] + usum1[3, 5] + usum1[5, 5] = 6 + 8 + 10 = 24
when m = 3 and n = 5,
totalv1[m, n] or totalv1[3, 5] = vsum1[3, 1] + vsum1[3, 3] + vsum1[3, 5] = 14 + 24 + 34 = 72
when m = 5 and n = 1,
totalu2[m, n] or totalu2[5, 1] = usum2[1, 1] + usum2[3, 1] + usum2[5, 1] = 7 + 13 + 19 = 39
when m = 1 and n = 5,
totalv2[m, n] or totalv2[1, 5] = vsum2[1, 1] + vsum2[1, 3] + vsum2[1, 5] = 15 + 35 + 55 = 105
when m = 5 and n = 1, totalv2[5, 1] = vsum2[5, 1] = 35
Please note that all of these should be done inside the Do-Loop.
Any kind help is much appreciated.
Thank you.
Attachments
Last edited: