Investment Studio > Expressions > Functions > Matrix > SUMXMY2

float sumxmy2(float array a, float array b)

Returns the sum of the squares of the differences of corresponding elements in arrays a and b.

Arrays with different dimensions are allowed as long as they all have the same number of elements (e.g. 2 x 3 and 3 x 2 arrays). Corresponding elements are determined by order of appearance (reading from left to right, top to bottom).

Non-numeric array elements are automatically converted to numbers. If conversion fails, they are treated as zeros.

Examples

=sumxmy2({{1, 2}, {3, 4}}, {{5, "6"}, {7, ""}})

equals (1- 5)^2 + (2 - 6)^2 + (3 - 7)^2 + (4 - 0)^2 = 64. The string "6" is autotranslated to 6, the string "" has no numeric value and so defaults to 0.

=sumxmy2({{1, 2}, {3, 4}, {5, 6}}, {{1, 2, 3} , {4, 5, 6}})

equals (1 - 1)^2 + (2 - 2)^2 + (3 - 3)^2 + (4 - 4)^2 + (5 - 5)^2 + (6 - 6)^2 = 0.

See also mmult, product, sum, sumproduct, sumx2my2, sumx2py2.