Use separation of variables to solve the initial boundary value problem: $$u_t=u_{xx}+2u \cos(t)\quad\text{on}\quad x \in (0,\pi),\quad t>0,$$ $$u(0,t)=u(\pi,t)=0,$$ $$u(x,0)=\phi(x).$$
I look up this old post too get an idea, but I am still not sure how to treat the $2u \cos(t)$ part. PDE separation of variables