This is the original question:
The space between two parallel infinite planes $ x=0 $ and $ x=L $ is filled with charge of the density $ \rho\left(x\right)=ax^{2}\left(L-x\right) $ where $ a $ is a constant. There are no other charges and no external uniform field.
Find the electric field in the whole space.
Now, I want to use Gauss's law to calculate the electric field. for $ x>L $ I chose a cylinder which its base is above the field (as you can see in the image below):
$ A $" />
Now we have from Gauss's law we have
$ E\cdot2A=\frac{1}{\varepsilon_{0}}\intop_{0}^{L}ax^{2}\left(L-x\right)dx\cdot ds $
$ E\cdot2A=\frac{A}{\varepsilon_{0}}\intop_{0}^{L}ax^{2}\left(L-X\right) $
And thus $ E=\frac{a}{2\varepsilon_{0}}\left(\frac{Lx^{3}}{3}-\frac{x^{4}}{4}\right) $
Now I want to find the electric field inside the layer. So I want to chose a cylinder as you can see in the image:
And I want to use Gauss's law again and write :
$ E\cdot2A=\frac{1}{\varepsilon_{0}}\intop_{?}^{?}\rho\left(x\right)dV $
But I'm not sure how to choose the upper and lower bound of the integral, in order to calculate the charge inside. The right answer according to my book is
$ E=\frac{a}{2\varepsilon_{0}}\left(\frac{Lx^{3}}{3}-\frac{x^{4}}{4}\right) $
And I get this result only if I'm choosing the lower bound to be $ 0 $ and the upper bound to be $ x $. But I do not understand why we can choose the lower bound to be $ 0 $ isnt lower base of the cylinder should be inside the layer as well as the upper base? and why I cannot get this result for a diffrent choice of upper and lower bounds?