Use the variables $x_1 = x, x_2 = x', x_3 = x''$, etc.
$x_1' = x_2$
$x_2' = x_3$
$x_3' = x_4$
$x_4' = -3\cos (6t)+21x_1-9x_2+14x_3$
My $x_4'$ is wrong and I'm not sure why.
Use the variables $x_1 = x, x_2 = x', x_3 = x''$, etc.
$x_1' = x_2$
$x_2' = x_3$
$x_3' = x_4$
$x_4' = -3\cos (6t)+21x_1-9x_2+14x_3$
My $x_4'$ is wrong and I'm not sure why.
From my comment, all you did wrong was forgetting to reverse the signs when you isolated $x^{(4)}$.
It's $x_4' = -3\cos (6t) -21x_1+9x_2-14x_3$
You know that $x_4'+14x_3-9x_2+21x_1=-3\cos(6t)$ by substitution. You must solve this equation for $x_4'$.