Investment Studio > Expressions > Functions > Matrix > SUMX2MY2

float sumx2my2(float array a, float array b)

Returns the sum of the differences of the squares of correspoding 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

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

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

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

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

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