0
$\begingroup$

$n=3$, $m=3$, $B$ - identity matrix $3 \times 3$

Trying to implement it in Mathematica, but can't figure out how to program the second term. The result is an error.

enter image description here

Clear["Derivative"]
ClearAll["Global`*"]

n = 3
m = 3
B = IdentityMatrix[3]

Sum[x[i] f[i], {i, 1, n}] + 
 Sum[x[i], {i, 1, n}] Sum[B[[i, j]] u[i], {j, 1, m}] - 
 1/T Log[\[Alpha]/\[Beta]] Sum[x[i]^2, {i, 1, n}]
$\endgroup$
9
  • $\begingroup$ You can not write Sum[B[[i, j]] u[i], {j, 1, m}]where i is undefined. $\endgroup$ Apr 16 at 17:03
  • $\begingroup$ @DanielHuber Sum[x[i] Sum[B[[i, j]] u[i], {j, 1, m}], {i, 1, n}] I tried this construction, but it seems to me that it is not correct. $\endgroup$
    – dtn
    Apr 16 at 17:06
  • $\begingroup$ @DanielHuber And no, I could be wrong, but it seems the last edit is correct? $\endgroup$
    – dtn
    Apr 16 at 17:35
  • $\begingroup$ No, I think the i in B[[i,j]] u[i] should indeed be bound by the same summation that the sum over x[i] is. Sum[x[i] Sum[B[[i, j]] u[i], {j, 1, m}], {i, 1, n}] should be correct. $\endgroup$
    – thorimur
    Apr 16 at 18:06
  • $\begingroup$ Also, what exactly is the error you're getting? $\endgroup$
    – thorimur
    Apr 16 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.