working task 4 for symmetric matrices