How to calculate the electric field using Gauss' s Law in this example? Suppose we have an infinite cylinder (infinite in the z-direction) with radius $a$. Inside it, there is free charge density given by $\rho = \rho_o \cos (kz - \omega t)$ and current density given by $\vec{J} = \hat{z} J_o \cos (kz - \omega t)$.
I am trying to calculate the electric field (inside the cylinder) using the integral form of Gauss' s Law. Due to symmetry, I think that the electric field will have only a radial component, thus $\vec{E} = \hat{r} E_r$.
Choosing a cylinder as a Gaussian surface with height $L$, we have
$\int_S \vec{E}\,\textrm{d}\vec{S} = \frac{Q_{enc}}{\epsilon_0} \Rightarrow \int_S \hat{r} E_r \hat{r} (r\,d\phi\,dz) = \frac{Q_{enc}}{\epsilon_0} \Rightarrow \int_{z=0}^L \int_{\phi=0}^{2 \pi} r E_r \,d\phi \,dz = \frac{Q_{enc}}{\epsilon_0} \Rightarrow 2 \pi L r E_r = \frac{Q_{enc}}{\epsilon_0}$
In order to calculate the total charge enclosed by the Gaussian surface, we integrate the charge density
$Q_{enc} = \int _0^{2 \pi }\int _0^r\int _0^{L } \rho_0 \cos (k z-t \omega ) r' \,d\varphi\,dr'\,dz = \frac{\pi  r^2 \rho_0 (\sin (k L-\omega t )+\sin ( \omega t ))}{k}$
Thus we get
$$E_r = \frac{r \rho_0 (\sin (k L- \omega t )+\sin ( \omega t ))}{2 \epsilon_0 k L}$$
This doesn't look correct, since we have dependence on $L$, which is arbitrary. Does anyone have any ideas where the problem might be with this solution?
 A: You'll not be able to exploit symmetry using Gauss' Law. Beacuse $\rho$ is not uniform along the $z$-axis you can't expect $\mathbf{E}$ to be radial nor you can take it outside the integral (it could have a dependence on $z$ as well). And the time varying current density $\mathbf J$ may create an electric field too. What you should do is solve for the retarded potentials
$$
\begin{align}
\phi(\mathbf r, t) &= \frac{1}{4\pi\epsilon_0} \int \frac{\rho(\mathbf r', t')}{|\mathbf r - \mathbf r'|} \, dv' \\ \\
\mathbf{A}(\mathbf r, t) &= \frac{\mu_0}{4\pi} \int \frac{\mathbf{J}(\mathbf r', t')}{|\mathbf r - \mathbf r'|} \, dv'
\end{align}
$$
(the integrals are over the primed variable) where $t'$ is the retarded time
$$
t' = t - \frac{|\mathbf r - \mathbf r'|}{c}
$$
and then calculate $\mathbf{E}$ via
$$
\mathbf E = - \boldsymbol \nabla \phi - \frac{\partial \mathbf A}{\partial t}.
$$
The integrals aren't necessarily easy to solve though, and you may have to resort to some approximation at some point (like taking the observation point far away from the cylinder such that $r' \ll r$).
