# Integration path with opposite direction from the unit vector

The task is to calculate the voltage between points $M$ and $N$ if the electric field vector is known to be $\vec{E}=\frac{V_0\cdot x^2}{a^3} \cdot \vec{i} + \frac{V_0 \cdot y}{a^2} \cdot \vec{j}$, where $V_0$ and $a$ are constants. I've provided a simple sketch below.

Formula for calculating voltage is: $$U_{MN}=\int_M ^N {\vec{E}\cdot d\vec{l}}$$

We are going to integrate from $M$ to $P$ and then from $P$ to $N$, because this way we integrate along one axis and consider only $x$ or $y$ component of $\vec{E}$ because one of them will be perpendicular to the path of integration and thus make no influence.

$U_{MN}=\int_M ^N {\vec{E}\cdot d\vec{l}} = \int_M ^P {{\vec{E}\cdot d\vec{l}}} + \int_P ^N {\vec{E}\cdot d\vec{l}}$

The first integral I understand.

$\int_M ^P {\vec{E} \cdot d\vec{l}}=\int_M ^P {\vec{E_x} \cdot d\vec{l}} =\int_M ^P {\frac{V_0\cdot x^2}{a^3} \cdot \vec{i}}\cdot d\vec{l} =\int_M ^P {\frac{V_0\cdot x^2}{a^3} \cdot \vec{i}}\cdot dx \cdot$ $\vec{i} = \int_a ^{4a} {\frac{V_0 \cdot {x^2}}{a^3}} \cdot {dx} = \dots$

What I do not understand is the second integral.

$$\int_P ^N \vec{E}\cdot d\vec{l} =$$ $$= \int_P ^N \vec{E_y} \cdot d\vec{l}$$

We are integrating from $P$ to $N$, so it should be that $d\vec{l} = dy \cdot -{\vec{j}}$, because the path $\vec{PN}$ is in the opposite direction from $\vec{j}$. Minus sign goes in front of the integral, and then we can swap integral limits(which destroys the minus sign):

$$= \int_P ^N {\frac{V_0 \cdot y}{a^2} \cdot \vec{j} \cdot dy \cdot -\vec{j}}$$ $$= \int_{\sqrt{7}a} ^{7a} {\frac{V_0 \cdot y}{a^2} \cdot dy}$$

and now we are integrating from $N$ to $M$ in the direction of $d\vec{y}$. When we get the final result, all we need to do is to perform a simple addition.

In the solution of this problem it says to change the sign of the integral AND swap the limits of integration. Then, $d\vec{l} = d\vec{y}$. Their integral turns out to be $$- \int_{\sqrt{7}a} ^{7a} {\frac{V_0 \cdot y}{a^2} \cdot dy}$$ and I don't understand why. I think they ignored that $d\vec{l}$ goes in the opposite direction of $\vec{j}$, but this is just a wild guess.

So, what interests me is how did the final integral become negative?

There's a problem in this equation: $$d\vec{l}=dy \cdot -\vec{j}$$ here $dy$ needs a minus sign. It is easier to see this writing the path.
The path of integration is parameterized by: $$\vec{l}=\vec{P}+(\vec{N}-\vec{P})\frac{y-y_P}{y_N-y_P} = \vec{P}+\hat{j}(y-7a) \\ y_p \le y \le y_N$$
Therefore $$d\vec{l}=\hat{j}dy$$ and $$\int_P^N E_y \cdot d\vec{l} = \int_P^N E_y \cdot \frac{d\vec{l}}{dy}dy = \int_{7a}^{\sqrt{7}a} \frac{V_0y}{a^2}\hat{j} \cdot \hat{j}dy = -\int_{\sqrt{7}a}^{7a} \frac{V_0y}{a^2} dy$$