# Physics Exercises/Electrostatics
### Electric field superposition principle

1. In words, and by equation, state the principle of superposition for electric fields.
In physics, the electric field superposition principle postulates that, for all linear systems, the net response at a given place and time caused by two or more charges is the sum of the responses which would have been caused by each charge individually.
Mathematically that can be written:
    ${\vec {E}}={\vec {E}}_{1}+{\vec {E}}_{2}+{\vec {E}}_{3}+...+{\vec {E}}_{n}=\sum _{i=1}^{n}{\vec {E}}_{i}=\sum _{i=1}^{n}{\frac {1}{4\pi \epsilon _{0}r^{2}}}{\vec {u_{r}}}_{i}$
Note that this is a vector equation. Hence one must add the components using vector rules.

## Finding the electric field associated with a dipole

1. An electric dipole is matched, equal but opposite, charges separated by a fixed distance. Find the electric field associated with an electric dipole. Perform this for three cases:
    a. Find the electric field perpendicular to the axis between dipole charges. Find the far field approximation.
    b. Find the electric field along the axis of the dipole charges. Compare the far field approximation for this case with that of a) above.
    c. Find the electric field perpendicular in a plane which includes the dipole charges
In physics, the electric dipole moment is a measure of the separation of positive and negative electrical charges in a system of charges, that is, a measure of the charge system's overall polarity. It is important in understanding practical matters like the construction of a capacitor.

### Finding the electric field perpendicular to the axis between dipole charges

To determine the electric field which result from the dipole charges in Figure 1 that are separated by a distance 2a, we simply sum the fields from each charge individually. Note that the fields are vectors.
    ${\vec {E}}={{\vec {E}}_{1}}+{{\vec {E}}_{2}}$
The distance of each charge (r) from the point where the electric field is measured is:
    $r={\sqrt {a^{2}+x^{2}}}$
The magnitude of the electric field (E$_1$) due to the first charge (q$_1$) and the magnitude of the electric field (E$_2$) due to the second charge (q$_2$) are the same although the directions are different.
$E_{1}=E_{2}={\frac {1}{4\pi \epsilon _{0}}}{\frac {q}{r^{2}}}={\frac {1}{4\pi \epsilon _{0}}}{\frac {q}{a^{2}+x^{2}}}$
The components of the electric field along the x axis $E_{1_{x}}$ and $E_{2_{x}}$ have the same magnitude but opposite directions and cancel each other out.
    $E_{1_{x}}+E_{2_{x}}=0$
As a result of this the horizontal components of the electric field vectors cancelling is that summing ${{\vec {E}}_{1}}$ and ${{\vec {E}}_{2}}$ reduces to summing $E_{1_{y}}$ and $E_{2_{y}}$. Further, the magnitude of the vertical components are identical, $E_{1_{y}}=E_{2_{y}}$. Since $\cos \theta ={\frac {adjacent}{hypotenuse}}$ finding the vertical component reduces to:
    $E_{1_{y}}=E_{2_{y}}=E_{1}\cos \theta \,\!$ or :$E_{y}=2E_{1}\cos \theta \,\!$
But we also know that:
$\cos \theta ={\frac {a}{\sqrt {a^{2}+x^{2}}}}$
So we can substitute this into the equation for $E\,\!$ which yields:
$E=2E_{1}\cos \theta \,\!={\frac {2}{4\pi \epsilon _{o}}}{\frac {q}{a^{2}+x^{2}}}{\frac {a}{\sqrt {a^{2}+x^{2}}}}={\frac {1}{4\pi \epsilon _{o}}}{\frac {2aq}{(a^{2}+x^{2})^{\frac {3}{2}}}}$
In the region distant from the dipole x is much greater than a (x>>a). This is commonly referred to as the "far field" region. We can find how the field behaves in the far field region by factoring out x.
$E={\frac {1}{4\pi \epsilon _{o}}}{\frac {2qa}{(a^{2}+x^{2})^{\frac {3}{2}}}}={\frac {1}{4\pi \epsilon _{o}}}{\frac {2qa}{x^{3}}}{\frac {1}{(1+{({\frac {a}{x}})}^{2})^{\frac {3}{2}}}}$
By inspection we can conclude that when x>>a then this approaches
$E\approx {\frac {1}{4\pi \epsilon _{o}}}{\frac {2qa}{x^{3}}}$
An important question for some analyses might be: over what range is the far field approximation valid? We can find out by using a binomial expansion (review of binomial expansion immediately below this section if you need it).
$E={\frac {1}{4\pi \epsilon _{o}}}{\frac {2qa}{(a^{2}+x^{2})^{\frac {3}{2}}}}={\frac {1}{4\pi \epsilon _{o}}}{\frac {2qa}{x^{3}}}{\frac {1}{(1+{({\frac {a}{x}})}^{2})^{\frac {3}{2}}}}$
Where we will expand
    ${\frac {1}{(1+{({\frac {a}{x}})}^{2})^{\frac {3}{2}}}}$$=(1+{({\frac {a}{x}})}^{2})^{-{\frac {3}{2}}}=1-{\frac {3}{2}}{({\frac {a}{x}})}^{2}+...$
If you want to use the approximation only when it introduces an error less than 1%, then - since the first term is unity, you want the second term to be less than 1/100th of unity, or:
    ${\frac {1}{100}}>{\frac {3}{2}}{\left({\frac {a}{x}}\right)}^{2}$
    ${\frac {2}{300}}>{\left({\frac {a}{x}}\right)}^{2}$
    ${\sqrt {\frac {2}{300}}}>{\left({\frac {a}{x}}\right)}$
    $x>{\sqrt {150}}\cdot a$
So if x is 12.3 times larger than a, this approximation is valid within 1%.

#### Binomial expansion review

Review of the binomial expansion:
    $\mathbf {(1+a)^{n}} =1+{\frac {n}{1!}}\cdot a+{\frac {n(n-1)}{2!}}\cdot a^{2}+{\frac {n(n-1)(n-2)}{3!}}\cdot a^{3}+...$
    $\mathbf {(1+a)^{-{\frac {3}{2}}}} =1+{\frac {1}{1!}}\cdot {\frac {-3}{2}}\cdot a+{\frac {1}{2!}}\cdot {\frac {-3}{2}}\cdot {\frac {-5}{2}}\cdot a^{2}+{\frac {1}{3!}}\cdot {\frac {-3}{2}}\cdot {\frac {-5}{2}}\cdot {\frac {-7}{2}}\cdot a^{3}+...$
informal source link

### Finding the electric field along the axis formed by dipole charges

The net electric field is the sum of the contributions to the electric field from the dipole charges.
${\vec {E}}={{\vec {E}}_{1}}+{{\vec {E}}_{2}}$
The first thing one always should do when solving a problem is to consider what you know by simple inspection. In this case the magnitude and layout of the charges tells use several things. Since they are equal and we know that the electric field from a point charge falls off as 1 over r$^2$ then we know that the nearest charge will always dominate. Further we also know that along the axis that we're calculating the electric field there will be no vertical component of the electric field.
$E_{1_{y}}=E_{2_{y}}=0$
So now we will calculate the magnitude of the electric field from each in the x direction: $E_{1_{x}}$ and $E_{2_{x}}$.
$E_{1}={\frac {1}{4\pi \epsilon _{0}}}{\frac {q}{{(r-a)}^{2}}}\qquad \qquad E_{2}={\frac {1}{4\pi \epsilon _{0}}}{\frac {-q}{{(r+a)}^{2}}}$
Adding the vector magnitudes $E_{1_{x}}$ and $E_{2_{x}}$
$E=E_{1_{x}}+E_{1_{x}}\,\!$
And substituting in the equations above yields:
$E={\frac {1}{4\pi \epsilon _{0}}}{\frac {q}{{(r-a)}^{2}}}+{\frac {1}{4\pi \epsilon _{0}}}{\frac {-q}{{(r+a)}^{2}}}={\frac {1}{4\pi \epsilon _{0}}}\left[{\frac {q}{{(r-a)}^{2}}}-{\frac {q}{{(r+a)}^{2}}}\right]={\frac {1}{4\pi \epsilon _{0}}}\ 4aq\ {\frac {r}{{(r^{2}-a^{2})}^{2}}}$
The quantity 2qa is defined as the dipole moment (p) and so we can substitute:
$p=2qa\,\!$
With that substitution we now get:
$E={\frac {1}{2\pi \epsilon _{0}}}{\frac {pr}{{(r^{2}-a^{2})}^{2}}}$
Consider the far field case (i.e., the case where $r\,\!$ >> $a\,\!$)
Then one can see that $r^{2}\,\!$ >> $a^{2}\,\!$ and that $r^{2}-a^{2}\,\!$ approaches $r^{2}\,\!$, which allows us to simplify the equation in the far field.
$E={\frac {1}{2\pi \epsilon _{0}}}{\frac {p}{r^{3}}}$
Note that one can use the binomial theorem just as in the section above to find out where this far field approximation (x>>a) is valid.

### Finding the electric field associated with a dipole anywhere on a plane

Now that you've solved for two special cases and determined that the dipole field falls off as ${\frac {1}{r^{3}}}$ at great distances (referred to as the far field), it is instructive to find the field's behavior off the axis.
Consider the case of an electric dipole's field at a point $P\,\!$ with the coordinates $(x,y)\,\!$ as represented in the figure. Note that we can represent the coordinates either as Cartesian, or as cylindrical.
    $r_{1}={\sqrt {{(y+a)}^{2}+x^{2}}}\quad \cos \alpha ={\frac {y+a}{\sqrt {{(y+a)}^{2}+x^{2}}}}\quad \sin \alpha ={\frac {x}{\sqrt {{(y+a)}^{2}+x^{2}}}}$
    $r_{2}={\sqrt {{(y-a)}^{2}+x^{2}}}\quad \cos \beta ={\frac {y-a}{\sqrt {{(y-a)}^{2}+x^{2}}}}\quad \sin \beta ={\frac {x}{\sqrt {{(y-a)}^{2}+x^{2}}}}$
In Cartesian coordinates the electric field at any point in the plane from each charge can be found as follows:
    ${E_{r}}_{1}={\frac {1}{4\pi \epsilon _{0}}}{\frac {+q}{{(y+a)}^{2}+x^{2}}}\quad {E_{r}}_{2}={\frac {1}{4\pi \epsilon _{0}}}{\frac {-q}{{(y-a)}^{2}+x^{2}}}$
We can apply the principle of superposition and add the fields from each of the charges, remembering that they are vectors so that the vertical components add to vertical and horizontal add to horizontal.
First finding the horizontal coordinates labeled as $E_{x}\,\!$:
    ${{E_{r}}_{1}}_{x}={\frac {1}{4\pi \epsilon _{0}}}{\frac {+q}{{(y+a)}^{2}+x^{2}}}\sin \alpha ={\frac {1}{4\pi \epsilon _{0}}}{\frac {+q}{{(y+a)}^{2}+x^{2}}}{\frac {x}{\sqrt {{(y+a)}^{2}+x^{2}}}}={\frac {1}{4\pi \epsilon _{0}}}{\frac {+qx}{{\left[{(y+a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}$
    ${{E_{r}}_{2}}_{x}={\frac {1}{4\pi \epsilon _{0}}}{\frac {-q}{{(y-a)}^{2}+x^{2}}}\sin \beta ={\frac {1}{4\pi \epsilon _{0}}}{\frac {-q}{{(y-a)}^{2}+x^{2}}}{\frac {x}{\sqrt {{y-a)}^{2}+x^{2}}}}={\frac {1}{4\pi \epsilon _{0}}}{\frac {-qx}{{\left[{(y-a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}$
Next finding the vertical components for each of the two charges labeled as $E_{y}\,\!$ we obtain:
    ${{E_{r}}_{1}}_{y}={\frac {1}{4\pi \epsilon _{0}}}{\frac {+q}{{(y+a)}^{2}+x^{2}}}\cos \alpha ={\frac {1}{4\pi \epsilon _{0}}}{\frac {+q}{{(y+a)}^{2}+x^{2}}}{\frac {y+a}{\sqrt {{(y+a)}^{2}+x^{2}}}}={\frac {1}{4\pi \epsilon _{0}}}{\frac {+q(y+a)}{{\left[{(y+a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}$
    ${{E_{r}}_{2}}_{y}={\frac {1}{4\pi \epsilon _{0}}}{\frac {-q}{{(y-a)}^{2}+x^{2}}}\cos \beta ={\frac {1}{4\pi \epsilon _{0}}}{\frac {-q}{{(y-a)}^{2}+x^{2}}}{\frac {y-a}{\sqrt {{y-a)}^{2}+x^{2}}}}={\frac {1}{4\pi \epsilon _{0}}}{\frac {-q(y-a)}{{\left[{(y-a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}$
Summing the horizontal components yields:
    $E_{x}={\frac {1}{4\pi \epsilon _{0}}}q\left\lbrack {\frac {x}{{\left[{(y+a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}-{\frac {x}{{\left[{(y-a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}\right\rbrack$
And for large r (either large x, large y, or their combination) this becomes:
    $E_{x}={\frac {qa}{2\pi \epsilon _{0}}}{\frac {1}{r^{3}}}$
Summing the vertical components yields:
    $E_{y}={\frac {1}{4\pi \epsilon _{0}}}q\left\lbrack {\frac {y+a}{{\left[{(y+a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}-{\frac {y-a}{{\left[{(y-a)}^{2}+x^{2}\right]}^{\frac {3}{2}}}}\right\rbrack$

## Finding the electric field associated with an electric quadrupole

The electric field measured at point along the vertical axis due to any single charge along the horizontal axis (shown in Figure 3) is:
    $E_{q}={\frac {q}{4\pi \epsilon _{o}r^{2}}}$
So the center charges contribute:
    $E_{2q}={\frac {2q}{4\pi \epsilon _{o}r^{2}}}$
While the left and right charges contribute a total field of magnitude:
    $E_{-q}={\frac {-q}{4\pi \epsilon _{o}(r^{2}+d^{2})}}$
By inspection we can see that the horizontal components of the electric field cancel out. Only the vertical components are left. So we multiply by
$sin\theta ={\frac {r}{\sqrt {r^{2}+d^{2}}}}$
To get the vertical component of the electric field for a single negative charge:
    $E_{-q}={\frac {-q}{4\pi \epsilon _{o}(r^{2}+d^{2})}}{\frac {r}{\sqrt {r^{2}+d^{2}}}}$
And for the two negative charges together we get:
    $E_{-2q}={\frac {-2q}{4\pi \epsilon _{o}(r^{2}+d^{2})}}{\frac {r}{\sqrt {r^{2}+d^{2}}}}$
Now we can add to obtain the total vertical component of the electric field.
    $E=E_{2q}+E_{-2q}={\frac {2q}{4\pi \epsilon _{o}r^{2}}}+{\frac {-2q}{4\pi \epsilon _{o}(r^{2}+d^{2})}}{\frac {r}{\sqrt {r^{2}+d^{2}}}}$
Which simplifies to:
    $E={\frac {q}{2\pi \epsilon _{o}}}\left[{\frac {1}{r^{2}}}-{\frac {r}{{(r^{2}+d^{2})}^{\frac {3}{2}}}}\right]$
Factoring out r$^3$ from the denominator's final term yields:
    $E={\frac {q}{2\pi \epsilon _{o}}}\left[{\frac {1}{r^{2}}}-{\frac {r}{{r^{3}(1+({\frac {d}{r}})^{2})}^{\frac {3}{2}}}}\right]$
Which reduces to:
    $E={\frac {q}{2\pi \epsilon _{o}r^{2}}}\left[1-{\frac {1}{{(1+({\frac {d}{r}})^{2})}^{\frac {3}{2}}}}\right]$
So now we have a perfectly good equation for calculating the field. An engineer might think that sufficient since they can calculate the value when they need it, but a physicist would like to know how this behaves in the "far field" where r >> d. Fortunately we have a tool - our friend the binomial expansion - which allows us to answer the far field question, as follows:
    $\left[1-{\frac {1}{{(1+({\frac {d}{r}})^{2})}^{\frac {3}{2}}}}\right]=\left[1-{{\left(1+\left({\frac {d}{r}}\right)^{2}\right)}^{-{\frac {3}{2}}}}\right]=\left[1-\left(1-{\frac {3}{2}}\left({\frac {d}{r}}\right)^{2}\right)+...\right]={\frac {3}{2}}\left({\frac {d}{r}}\right)^{2}$
Substituting back into the original equation:
    $E={\frac {q}{2\pi \epsilon _{o}r^{2}}}{\frac {3}{2}}\left({\frac {d}{r}}\right)^{2}$
Simplifying, we find that in the far field when r >> d the electric field from a quadrupole falls off as ${\frac {1}{r^{4}}}$
    $E={\frac {3qd^{2}}{4\pi \epsilon _{o}r^{4}}}$

## Electric field associated with a line charge

* A very long solid nonconducting cylinder of radius R$_0$ and length L (R$_0$ << L) possesses a uniform volume charge density ρ$_E$ (C/m$^3$). For points far from the ends and for which r << L,
** Find electric fields for all r, distance from axis of cylinder. You may need separate expressions for r < R$_0$ and r > R$_0$. Show that electric field is continuous at r = R$_0$, i.e. two expressions for electric fields agree at r = R$_0$.
** Describe the motion of a small free charge Q of opposite sign (i.e. Q ρ$_E$ < 0) placed inside the cylinder. Find the frequency of oscillation $\nu$ if the charge oscillates about the axis of cylinder. (Note: $\nu$, frequency, has units of cycles / second, while $\omega$, angular frequency, has units of radians / second.)
** Let's change the problem and say we have a cylindrical shell of charge (of radius R$_0$, and σ$_E$ so that the total charge remains the same). How do the expressions for electric fields change for either regions r < R$_0$ or r > R$_0$? Is the electric field still continuous? Give a plausible argument why we might not expect electric field to be continuous.

## Find the electric field for a finite line with uniform unit charge of λ coulombs per unit length

The figure shows an finitely long line chage with linear charge density of $\lambda \,\!={\frac {dq}{dx}}$. The charge extends from x = -a to x = +b which are arbitrary (although not infinite) and are not shown on the figure.
Just as it the derivation for the infinite lint, the magnitude of the electric field which results from a short section dx of this line charge as measured at point P is a result of the charge $dq=\lambda dx\,\!$:
And with that charge we can calculate the field contribution (dE) from dq as:
    $dE={\frac {1}{4\pi {\epsilon }_{0}}}{\frac {dq}{r^{2}}}={\frac {1}{4\pi {\epsilon }_{0}}}{\frac {\lambda dx}{x^{2}+y^{2}}}$  (1)
We can no longer argue by symmetry that the electric field will be the same at any point of equal separation from the infinite line charge, so we can solve this in detail, which we will do using 2 dimensions. Once we have a solution for 2 dimensions, simple rotation around the line charge will allow us to determine the field in the 3rd dimension.
The electric field is a vector which we'll represent as $d{\vec {E}}$. This we'll separate into 2-dimensional Cartesian components:
    $dE_{x}=-dE\sin \theta \,\!$ and $dE_{y}=dE\cos \theta \,\!$
The sign of the electric field at $dE_{x}\,\!$ indicates the $d{\vec {E}}_{x}$ location of the point with respect to x.
We find the total electric field for the horizontal $E_{x}$ and vertical $E_{y}$ components to determine ${\vec {E}}$ at the point P by integrating. Note that $\sin \theta$ is used to find the components of the field horizontally, while $\cos \theta$ is used to find them vertically.
    $E_{x}=\int dE_{x}=-\int _{x=-a}^{x=+b}\sin \theta \,dE$
and
    $E_{y}=\int dE_{y}=\int _{x=-a}^{x=+b}\cos \theta \,dE$
Or in full vectorial form:
    ${\vec {E}}=\int _{L}\,d{\vec {E}}=\int _{L}{\frac {1}{4\pi \epsilon _{0}}}{\frac {dq}{r^{2}}}{\vec {u_{r}}}=\int _{L}{\frac {1}{4\pi \epsilon _{0}}}{\frac {\lambda dx}{r^{2}}}{\vec {u_{r}}}$
In this example the distance, r, from the charge to point P can be expressed in terms of Cartesian coordinates x and y.
$r={\sqrt {x^{2}+y^{2}}}$.
which allows us to calculation the magnitude of the electric field at point P from the charge dx at r using the equation. $dE={\frac {1}{4\pi {\epsilon }_{0}}}={\frac {1}{4\pi {\epsilon }_{0}}}{\frac {\lambda dx}{x^{2}+y^{2}}}$
    $\sin \theta ={\frac {opposite}{hypotenuse}}={\frac {x}{\sqrt {x^{2}+y^{2}}}}$ and $\cos \theta ={\frac {adjacent}{hypotenuse}}={\frac {y}{\sqrt {x^{2}+y^{2}}}}$
However we must recall that that magnitude corresponds to the vector $d{\vec {E}}$, which changes as one moves along the line. So we must find the component of $d{\vec {E}}$ which points in the x or in the y directions.
To find the component in the x direction $dE_{x}=-dE\sin \theta \,\!$ and to find it in the y direction apply $dE_{y}=dE\cos \theta \,\!$.
The x component of the field $d{\vec {E}}_{x}$ can be found by integrating from one end of the line source at -a to the other at a. If the line source is equally long to left and right, the net field in the x direction will cancel as below.
    $E_{x}=\int dE_{x}=-\int _{x=-a}^{x=+b}\sin \theta \,dE=-\int _{x=-a}^{x=+b}{\frac {x}{\sqrt {x^{2}+y^{2}}}}\,dE$
    $E_{x}=\int _{x=-a}^{x=+b}{\frac {x}{\sqrt {x^{2}+y^{2}}}},{\frac {1}{4\pi {\epsilon }_{0}}}{\frac {\lambda dx}{x^{2}+y^{2}}}$  (2)
    $E={\frac {\lambda }{4\pi {\epsilon }_{0}}}\int _{x=-a}^{x=+b}{\frac {xdx}{\left[{x^{2}+y^{2}}\right]^{\frac {3}{2}}}}$ (3)
    $E_{x}={\frac {\lambda }{4\pi {\epsilon }_{0}}}\left[-{\frac {1}{\left[a^{2}+y^{2}\right]^{\frac {1}{2}}}}+{\frac {1}{\left[b^{2}+y^{2}\right]^{\frac {1}{2}}}}\right]$  (4)

#### hold 1

Similarly the y component of the field $d{\vec {E}}_{y}$ can be found by integrating from one end of the line source at -a to the other at a.
    $E_{y}=\int dE_{y}=\int _{x=-a}^{x=+b}\cos \theta \,dE=\int _{x=-a}^{x=+b}{\frac {y}{\sqrt {x^{2}+y^{2}}}}\,dE$
And substituting in the equation above we get:
    $E_{y}=\int _{x=-a}^{x=+b}{\frac {y}{\sqrt {x^{2}+y^{2}}}}\,{\frac {1}{4\pi {\epsilon }_{0}}}{\frac {\lambda dx}{x^{2}+y^{2}}}={\frac {\lambda y}{4\pi {\epsilon }_{0}}}\int _{x=-a}^{x=+b}{\frac {dx}{\left[x^{2}+y^{2}\right]^{\frac {3}{2}}}}$  (5)
    $E_{y}={\frac {\lambda y}{4\pi {\epsilon }_{0}}}\int _{x=-a}^{x=+b}{\frac {dx}{\left[x^{2}+y^{2}\right]^{\frac {3}{2}}}}$  (6)
    $E_{y}={\frac {\lambda }{4\pi {\epsilon }_{0}y}}\left[{\frac {x}{\left[x^{2}+y^{2}\right]^{\frac {1}{2}}}}\right]_{x=-a}^{x=+b}$  (7)

## Find the electric field for an infinite line with uniform unit charge of λ coulombs per unit length

The figure shows an infinitely long line chage with linear charge density of $\lambda \,\!={\frac {dq}{dx}}$.
The magnitude of the electric field which results from a short section dx of this line charge as measured at point P is a result of the charge $dq=\lambda dx\,\!$:
And with that charge we can calculate the field contribution (dE) from dq as:
    $dE={\frac {1}{4\pi {\epsilon }_{0}}}{\frac {dq}{r^{2}}}={\frac {1}{4\pi {\epsilon }_{0}}}{\frac {\lambda dx}{x^{2}+y^{2}}}$  (1)
Since we can argue by symmetry that the electric field will be the same at any point of equal separation from the infinite line charge, we can solve this in using 2 dimensions. Once we have a solution for 2 dimensions, simple rotation around the line charge will provide the field in the 3rd dimension.
The electric field is a vector which we'll represent as $d{\vec {E}}$. This we'll separate into 2-dimensional Cartesian components:
    $dE_{x}=-dE\sin \theta \,\!$ and $dE_{y}=dE\cos \theta \,\!$
The sign of the electric field at $dE_{x}\,\!$ indicates the $d{\vec {E}}_{x}$ location of the point with respect to x.
We find the total electric field for the horizontal $E_{x}$ and vertical $E_{y}$ components to determine ${\vec {E}}$ at the point P by integrating. Note that $\sin \theta$ is used to find the components of the field horizontally, while $\cos \theta$ is used to find them vertically.
    $E_{x}=\int dE_{x}=-\int _{x=-\infty }^{x=+\infty }\sin \theta \,dE$
and
    $E_{y}=\int dE_{y}=\int _{x=-\infty }^{x=+\infty }\cos \theta \,dE$
In these expressions $E_{x}\,\!$> must integrate to zero because every element of charge to the left of the perpendicular point P has a corresponding element on the right so that their contributions to the field in the horizontal direction cancel each other. So ${\vec {E}}$ points in the vertical direction only. As for the electric field contributions to $E_{y}\,\!$, the right half and left half of the charged lines will make an equal contribution, so we can write:
    $E=E_{y}=2\int _{x=0}^{x=+\infty }\cos \theta \,dE$
Substituting the expression (1) above into this equation we get:
    $E=2\int _{x=0}^{x=+\infty }\cos \theta \,{\frac {1}{4\pi {\epsilon }_{0}}}{\frac {\lambda dx}{x^{2}+y^{2}}}={\frac {\lambda }{2\pi {\epsilon }_{0}}}\int _{x=0}^{x=+\infty }\cos \theta \,{\frac {dx}{x^{2}+y^{2}}}$ (2)
By definition $\tan \theta ={\frac {x}{y}}$, which we can write as $x=y\tan \theta \,\!$. Differentiating this expression yields: $dx=y{\sec }^{2}\theta d\theta \,\!$. Substitute this into (2) and you will get:
    $E={\frac {\lambda }{2\pi {\epsilon }_{0}}}\int _{x=0}^{x=+\infty }\cos \theta \,{\frac {y{\sec }^{2}\theta d\theta }{x^{2}+y^{2}}}={\frac {\lambda }{2\pi {\epsilon }_{0}}}\int _{x=0}^{x=+\infty }{\frac {y}{x^{2}+y^{2}}}\cos \theta {\sec }^{2}\theta d\theta$ (3)
Applying further trigonometric relationships: $\cos \theta ={\frac {y}{r}}$, $\sec \theta ={\frac {r}{y}}\quad$ and $\quad x^{2}+y^{2}=r^{2}\,\!$, we can establish equivalencies:
    ${\frac {y}{x^{2}+y^{2}}}\cos \theta {\sec }^{2}\theta d\theta ={\frac {y}{r^{2}}}{\frac {y}{r}}{\frac {r^{2}}{y^{2}}}={\frac {y}{ry}}={\frac {\cos \theta }{y}}$
Which can the be substituted into equation (3) to yield a significantly simplified integral:
    $E={\frac {\lambda }{2\pi {\epsilon }_{0}y}}\int _{x=0}^{x=+\infty }\cos \theta d\theta$
To evaluate this we need only observe that $x\rightarrow 0\,\!$, $\theta \rightarrow 0\,\!$ and similarly $x\rightarrow +\infty \,\!$, $\theta \rightarrow {\frac {\pi }{2}}\,\!$, to simplify our range of integration to:
    $E={\frac {\lambda }{2\pi {\epsilon }_{0}y}}\int _{\theta =0}^{\theta ={\frac {\pi }{2}}}\cos \theta d\theta ={\frac {\lambda }{2\pi {\epsilon }_{0}y}}{\Bigg\sin {\frac {\pi }{2}}-\sin 0{\Bigg ]}={\frac {\lambda }{2\pi {\epsilon }_{0}y}}$
Which yields a final solution:
    $E={\frac {\lambda }{2\pi {\epsilon }_{0}y}}$
And this can be generalized for any point at distance r from the line charge to:
* $E={\frac {\lambda }{2\pi {\epsilon }_{0}r}}$