# How to convert this formula to matrix form (compact form)

I have a simple formula want to insert within my article, however I don't know how to simplify it in matrix form. It would be grateful if you could answer me.

Description of the formula: The notation of A[i] denotes the i-th feature of vector A. Here x_pi and x_qj along with G_q are one dimensional vectors. The result must be a real number.

$Replace\left( {{x_{pi}},{x_{qj}},{G_q}} \right) = \mathop \sum \limits_{f = 1}^d ({x_{pi}}\left[ f \right] - {x_{qj}}\left[ f \right])\left( {2\left( {{x_{qj}}\left[ f \right] - {{\bar x}_q}\left[ f \right]} \right) + ({x_{pi}}\left[ f \right] - {x_{qj}}\left[ f \right])(\left| {{G_q}} \right| - 1)/|{G_q}|} \right)$

-
 Your notation is hard to follow. Are $pi, qj$ a single number or a pair of numbers? Why $x_{pi}$ but $\overline{x}_q$? – copper.hat Aug 28 '12 at 15:47 p and i are different integer numbers, and they denote an index for x. \bar{x} denotes another vector (i.e. mean(x)) I fogotten to mention. |G| is a simple integer number – remo Aug 28 '12 at 16:01