We are a group of students who are struggling with transforming this formula to run in mathematica. In fact there are many formulas that we are struggling with, but if we are able to see how this is solved we should be able to see how it is done and apply it to the other formulas ourself.

We tried using spares Array but was not able to compute it.

enter image description here

Subscript[x, 1]={{1,2}}
Subscript[x, 2]={{1,3}}\[Transpose]
Subscript[x, 3]={{1,4}}\[Transpose]

T is set to 3. and Subscript[w, j]= 1-j/H

\*UnderoverscriptBox[\(\[Sum]\), \(t = 1\), \(T\)]
SubscriptBox[\(e\), \(t\)], \(2\)]\)Subscript[x, t]Subscript[x, t]\[Transpose]+1/TUnderoverscript[\[Sum], j=1, H-1]Subscript[w, j]Underoverscript[\[Sum], s=j+1, T]Subscript[e, s]Subscript[e, s-j](Subscript[x, s]Subscript[x, s-j]\[Transpose]+Subscript[x, s-j]Subscript[x, s]\[Transpose])
  • 2
    $\begingroup$ Alexander, explain please a bit more, what are the objects you operate with (vectors? matrices? other objects, what then?), and what are you going to achieve with them: calculate the result of operations, or display them in some text? In the latter case please specify, where in the text: e.g. in a separate line, a numbered equation and so on. $\endgroup$ Jan 28 '14 at 8:18
  • 1
    $\begingroup$ Alexander, while the fancy 2D typesetting looks good in the Mathematica front end, as you can see it doesn't translate to text very nicely. May I suggest you write your expression in one-dimensional InputForm, e.g. instead of $\sum _{i=1}^n x_i$ use Sum[Subscript[x, i], {i, 1, n}]. Personally I would also use downvalues instead of subscripts, e.g. instead of Subscript[x,i] use x[i]. $\endgroup$ Jan 28 '14 at 9:02
  • $\begingroup$ Write your vectors as one dimensional, multiply them with Dot (or infix .), and don't do all the transposing of matrices. This is the gist of @belisarius' response, and it's a good one (note to self: upvote it). $\endgroup$ Feb 27 '14 at 14:49


x = {{1, 2}, {1, 3}, {1, 4}}
e = {2, 4, 5};
T = 3;
H = 4(*I guess ??*);
w[j_] := 1 - j/H
res = 1/T Sum[e[[t]]^2 (x[[t]].x[[t]]), {t, T}] +
      1/T Sum[ w[j] Sum[2 e[[s]] e[[s-j]] (x[[s]].x[[s-j]]), {s, j+1, T}], {j, H-1}]
  • $\begingroup$ The left hand side of the + sign is right if you take into account that the x1 is suppose to be a column vector. so for the dimensions and the formula to be correctly calculated we need to take the {x[[t]]}transpose.{x[[t]]}, the reason for this is that in the formula the first is a column while the second is a row. In your x that you have defined x[[1]] comes out as a row and not a column you therefor need to transpose it. $\endgroup$
    Jan 30 '14 at 17:16
  • $\begingroup$ the calculations on the right hand side of the + sign I am not sure of, there is a problem there with the transpose as well, but I do not get how the SUM[Sum] work, in which order does mathematica do the summation? $\endgroup$
    Jan 30 '14 at 17:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.