An electric dipole is a pair of charges having equal magnitudes but opposite sign separated at a distance, say \(d\). When such a dipole is placed in a uniform electric field, the electric field exerts force on the dipole which then rotates the dipole in clockwise or anticlockwise direction.
Let's consider a positive and a negative charge having equal magnitudes separated at a distance \(d\). Such arrangement of charges is called an electric dipole. It's a good idea to start with a coordinate system as shown in Figure 1.
Now we determine the electric field at any point \(p\) which is located at the same distance \(r\) from both charges. Both charges have the same magnitude so the electric field magnitude at the point \(p\) is also the same which is
\[E = k\frac{q}{{{r^2}}}\]
The y-component of electric field due to the electric dipole is a zero vector, that is the y-component of one charge is equal in magnitude and opposite in direction to the y-component of another charge. The y-component of \(\vec E_1\) due to positive charge is \(E \sin \theta \hat j\) and the y-component of \(\vec E_2\) due to negative charge is \(-E \sin \theta \hat j\), so they cancel each other. Here the unit vector \(\hat j\) is the unit vector along y-axis. Both x-components of electric fields due to the electric dipole lie along the same line (parallel to x-axis) in the same direction and therefore the electric field at the point \(p\) is only due to the x-components of electric fields of both charges.
The x-component of electric field due to one charge is \(E_x = E \cos \theta\) which is equal in both magnitude and direction to the x-component of electric field of another charge. So the total electric filed at the point \(p\) is twice the x-component of electric field due to one charge that is, \(E = 2E_x = 2E \cos \theta\). You know the electric field magnitude \(E\) from the above equation and therefore, the total electric field is
\[E = k\frac{2q \cos \theta}{r^2} \tag{1} \label{1}\]
In vector form if the unit vector towards x-direction is \(\hat i\), the above equation is
\[\vec E = k{\frac{2q \cos \theta}{r^2}} \hat i \tag{2} \label{2}\]