2
// cosm - computes the matrix cosine
6
// a : square hermitian or diagonalizable matrix
7
// x : square hermitian matrix
10
if type(a)<>1 then error(53),end
11
if a==[] then x=[],return,end
13
if norm(imag(a),1)==0 then
16
x=0.5*(expm(%i*a)+expm(-%i*a));