If a Gaussian surface is assumed in a non-uniform electric field and charge enclosed is zero, is the net electric flux coming out still zero

chargeelectric-fieldselectrostaticsgauss-law

Assume a Gaussian surface in a non-uniform electric field that is directed along X-axis. Say the field is getting weaker as we go along positive X direction and it's constant along Y and Z directions. Then, if the Gaussian surface is a cube and charge enclosed is zero, the electric flux coming into the surface is more than that flowing out. So, shouldn't the net electric flux be non-zero contradicting Gauss's law?

Does it mean such an electric field is impossible without a charge being distributed along the path?

Best Answer

Your question contains a contradiction. Basically the last sentence of your question is completely right. If $\mathbf{E}=f(x)\hat{x}$, then $$ \frac{\rho}{\epsilon_0}=\nabla\cdot\mathbf{E}=f'(x)\neq 0 $$ So in order to have an electric field that is only in the $\hat{x}$ direction and changes in magnitude with $x$, there must be charge present. With this electric field, Gaussian surfaces have nonzero flux because there is charge inside of them.

If there is no charge in a Gaussian surface, the net flux through it is zero, and this electric field is not possible. This is an absolute law. There are no exceptions.

This question reminds me of this other one, where OP thought they could specify the charge on a conductor and the voltage. Just like in that situation, the electric field (or rather the divergence of the electric field) is determined by the charge. You cannot freely choose any electric field and separately say there is no charge present.