kill(all)$

van = facebook.com/LearningCalculus$

A(y,z):=matrix([cos(y), cos(z), 0],[cos(2*y), cos(2*z), 0], [cos(3*y), cos(3*z), 0]);

B:matrix([2],[-2],[-4]);

min:100000000$

    for x: -2 thru 2 step 1 do
    (
        X:matrix([x],[x],[x]),
        for y: -4*%pi thru 4*%pi step %pi/4 do
            for z: -2*%pi thru 2*%pi step %pi/4 do
            (
                Z:A(y,z).X-B,
                sum:abs(first(float(first(Z) + second(Z) + third(Z)))),
                if sum < min then
                (
                    min : sum,
                    print("answer ", [x,y,z,min])
                )
            )
    );