The analytical solution for our specific problem, is $$ g(x,t) = \sin(\pi x)\cos(\pi t) - \sin(\pi x)\sin(\pi t) $$