# Electric field at a general point for a finite line charge

I am trying to evaluate the electric field at a general point (not only just along an axis) for a finite length of charge. I am getting a very weird integral and also my attempt failed the sanity check. First let me introduce the problem statement and my attempt:

Problem: A finite length of continuous line charge that has density λ is placed on the y-axis between y=-a/2 to y=a/2. We need to find the electric field due to this charge at a point $$P(p_x,p_y)$$. See the attached picture below.

My attempt: We know that $$\vec{E} = \frac{\lambda}{4\pi\epsilon_0} \int_{-a/2}^{a/2} \frac{\hat{s}}{s^2} dy$$ where $$\vec{s}$$ is the separation vector. So, we have: $$\vec{r} = p_x \hat{i} + p_y \hat{j}$$ $$\vec{r'} = y \hat{j}$$ $$\vec{s} = \vec{r} - \vec{r'} = p_x \hat{i} + (p_y - y) \hat{j}$$ $$s^2 = p_x^2 + (p_y-y)^2$$ $$\hat{s} = \frac{p_x \hat{i} + (p_y - y) \hat{j}}{\left( p_x^2 + (p_y-y)^2 \right)^{1/2}}$$ Therefore, $$\vec{E} = \frac{\lambda}{4 \pi \epsilon_0} \int_{-a/2}^{a/2} \frac{p_x \hat{i} + (p_y - y) \hat{j}}{\left( p_x^2 + (p_y-y)^2 \right)^{3/2}} dy$$

Now, notice that here if I put $$p_x = 0$$, I will get a zero x-component of the electric field. However, when I evaluate the integral for x-component using Mathematica, I get an expression like:

$$\int \frac{p_x \hat{i}}{\left( p_x^2 + (p_y-y)^2 \right)^{3/2}}dy = \frac{p_y-y}{p_x\left( p_x^2 + (p_y-y)^2 \right)^{1/2}}$$

So, when the charge is on the y-axis, from the left side of the equation (the integral), we get that the x-component of the electric field should be 0. However, from the right side of the equation (the evaluated integral), we see that for $$p_x=0$$, the expression will be undefined.

So, my question is that (1) why is this discrepancy happening? Where is my mistake? (2) is this approach the correct way to obtain the electric field at a general point for finite charge density? What is the correct description for this? I couldn't find it on the internet.

## 1 Answer

For a point on the y-axis, above or below the charged segment, the x component will be zero. Approaching the segment parallel to the x-axis, the field will eventually approximate the field around a line charge, (infinite line, constant linear charge density) and this approaches infinity as x approaches zero.

The field is mathematically undefined within the charged segment, but regard it as infinite in the x-z plane.

For the points at the end of the segment you can choose an approach path to make the x component appear to take any value you feel like!