**Positive electric charge Q is distributed uniformly along a line (you could imagine it as a very thin rod) with length 2a, lying along the y-axis between y = -a and y = +a. A point p lies at x along x-axis. Find the electric field at point P.**

Linear charge density, $\lambda$:

$$\lambda = \frac{Q}{2a}$$

To find the dE, we will need dQ. dQ:

$$\begin{aligned}dQ &= \lambda \, dy \\ &= \frac{Q}{2a} \, dy \end{aligned}$$

Notice the symmetry in the problem. The vertical (y-axis) component of the electric field at P will vanish due to cancellation. Hence, only the horizontal (x-axis) component survives.

$$\begin{aligned} dE_{x} &= \frac{dQ}{4 \pi \epsilon_{0} \left(x^{2} + y^{2} \right)} \, \text{cos} \, \alpha \\ &= \frac{x}{4 \pi \epsilon_{0} (x^{2} + y^{2})^{\frac{3}{2}}} \, dQ \\ &= \frac{xQ}{8 \pi a \epsilon_{0} (x^{2} + y^{2})^{\frac{3}{2}}} \, dy \end{aligned}$$

You can use matlab or mathematica to evaluate the integral above from -a to a. Or you can use the integration result: $\int \frac{dx}{ \left( a^{2} + x^{2} \right)^{\frac{3}{2}}} = \frac{1}{a^{2}} \frac{x}{\sqrt{a^{2} +x^{2}}}$ from integration table.

You will obtain:

$$\vec{E} = \frac{Q}{4 \pi \epsilon_{0} x \sqrt{x^{2} + a^{2}}} \, \vec{i}$$

Next: Electric Field Of Uniformly Charged Disk