Consider a positively charged infinite slab with uniform charge density $\rho_1$ and thickness $4a.$ This slab is oriented such that the two faces of the slab are located on the planes $x=-2a$ and $x=2*a,$ respectively. A positively charged solid sphere of radius $R=2a$ has its center located at the point on the $x$-axis at $x=6a,$ as shown in the figure below ( Given as a google drive link). The sphere has volume charge density , $\rho_2(r)=br$ where $r$ is the radial distance from the center of the sphere and $b$ is a positive constant with unit dimensions $C\cdot\text{m}^{-1}.$ Let $\hat{\mathbf{i}}$ be the unit vector pointing towards the right.
https://drive.google.com/file/d/1MFeJNl7DGuCNV5CdAXc3k1cjD9HffPsx/view?usp=drivesdk
Determine the direction and magnitude of the electric field at the point $x_A=+a.$
I got the answer $$E= a/\epsilon_0(-8\rho_2/75+\rho_1)\,\hat{\mathbf{i}}$$ But I don't know how to use $\rho_2(r)=br;$ can someone help me with this problem?
We compute this field in two steps. First, we find the electric field due to the slab, and then add to that the electric field due to the sphere.
Slab: Gauss's Law says that $$\frac{Q_{\text{enc}}}{\varepsilon_0}=\iint_S\mathbf{E}\cdot d\mathbf{A}.$$ We can use this to find the electric field due to the slab. Note that, by symmetry, the "quarter" of the slab to the right of $a$ cancels out the "quarter" of the slab immediately to the left of $a$. Therefore, for the slab portion, we only need to find the field at $a$ due to the left half of the slab. We employ a Gaussian surface of a cylinder, axis coincident with the $x$-axis, of radius $c,$ say. We will say that its length is $4a,$ and the right-hand end of it is at $x=a$. The charge enclosed is therefore $Q_{\text{enc}}=\rho_1\cdot V=\rho_1\pi c^2(2a)=2\pi ac^2\rho_1.$ By symmetry, again, we can see that there cannot be any $y$ or $z$ component of the field due to the slab at $x=a,$ because of rotational symmetry. It follows that the surface integral is zero on the lateral surface, and only has values at the endcaps. It will be constant on the endcaps, so that the field $E$ should be able to pull out of the integral (this is standard when using Gauss's Law, which is really only useful when there's enough symmetry to make this happen). So we have $$\frac{2\pi ac^2\rho_1}{\varepsilon_0}=2\cdot E\pi c^2,\;\text{since there are two endcaps},$$ making $$E=\frac{a\rho_1}{\varepsilon_0}.$$ So this is the contribution due to the slab.
Sphere: We need to integrate to find the total charge. This is straight-forward, as the density depends only on the radial distance: $$Q=\iiint_V\rho_2\,dV=\int_0^{2a}br\,4\pi r^2\,dr=4\pi b\int_0^{2a}r^3\,dr =4\pi b \,\frac{r^4}{4}\Bigg|_0^{2a}=16\pi a^4b.$$ Now the electric field due to a point charge $Q$ is given by $$E=\frac{1}{4\pi\varepsilon_0}\,\frac{Q}{r^2}=\frac{16\pi a^4b}{4\pi\varepsilon_0(5a)^2}=\frac{4a^2b}{25\varepsilon_0}.$$ The distance from the center of the sphere to the point where you're trying to calculate the field is $5a,$ and the charge is apparently positive.
Final answer is the slab value minus the sphere value (if $b>0,$ they're going to cancel): $$\mathbf{E}=\left(\frac{a\rho_1}{\varepsilon_0}-\frac{4a^2b}{25\varepsilon_0}\right)\hat{\mathbf{i}}.$$