# mat_ineq.ma
# maple commands to produce counterexample to the non-commutative case of
# the inequality in my paper, An Inequality related to the Birthday Problem.
# See http://barnyard.syr.edu/research.shtml
#
# Load linear algebra package
with(linalg):
# Define three 2x2 matrices
A := Matrix(2,2,[[1,1],[1,1]]);
B := Matrix(2,2,[[1,2],[2,4]]);
C := Matrix(2,2,[[1,3],[3,9]]);
# Form the average of the sum of all possible products of distinct matrices
mylhs := evalm((A&*B&*C+B&*A&*C+A&*C&*B+C&*A&*B+B&*C&*A+C&*B&*A)*( 1/6));
# Form the arithmetic average of the 3 matrices
myrhs := evalm(((A+B+C)*(1/3))^3);
# Form the difference of the two sides of the conjectured inequality
mydiff := evalm(myrhs - mylhs);
# Form the determinant of the difference
det(mydiff);
# Since the determinant is strictly negative, the difference is not
# non-negative definite.