Akm[k_,m_]:=Piecewise[{{(Eax2 + Eay2z2 + Eayz + Ebxy + Ebxz)/5, k == 0 && m == 0}, {0, (k != 2 && k != 4) || (k != 4 && m != -2 && m != -1 && m != 0 && m != 1 && m != 2) || (m != -4 && m != -3 && m != -2 && m != -1 && m != 0 && m != 1 && m != 2 && m != 3 && m != 4)}, {(Sqrt[6]*Eax2 - Sqrt[6]*Eay2z2 - Sqrt[6]*Eayz + Sqrt[6]*Ebxz + 2*Sqrt[2]*May2z2x2)/4, k == 2 && (m == -2 || m == 2)}, {(I/2)*(-2*Sqrt[2]*Max2yz + Sqrt[6]*Mb), k == 2 && (m == -1 || m == 1)}, {(-Eax2 + Eay2z2 + Eayz - 2*Ebxy + Ebxz + 2*Sqrt[3]*May2z2x2)/2, k == 2 && m == 0}, {(3*Sqrt[7/10]*(3*Eax2 + Eay2z2 - 4*Ebxy - 2*Sqrt[3]*May2z2x2))/8, k == 4 && (m == -4 || m == 4)}, {((3*I)/4)*Sqrt[7/5]*(Sqrt[3]*Max2yz - May2z2yz + 2*Mb), k == 4 && (m == -3 || m == 3)}, {(-3*(3*Eax2 - 3*Eay2z2 + 4*Eayz - 4*Ebxz + 2*Sqrt[3]*May2z2x2))/(4*Sqrt[10]), k == 4 && (m == -2 || m == 2)}, {(((-3*I)/4)*(Sqrt[3]*Max2yz + 7*May2z2yz + 2*Mb))/Sqrt[5], k == 4 && (m == -1 || m == 1)}}, (3*(9*Eax2 + 19*Eay2z2 + 2*(-8*Eayz + 2*Ebxy - 8*Ebxz + 5*Sqrt[3]*May2z2x2)))/40]