clear reset(symengine) syms t real syms w positive M = [ 0 1 ; -w^2 0 ] [U,D] = eig(M) B = U * expm(D*t) syms x0 dx0 real q0 = [x0 ; dx0] alpha = inv(U) * q0 q_general = simplify( B * alpha )