Direction of integration and boundary limits in electromagnetism? I have encountered several problems regarding the choice of direction of integration and the boundary limits, this semester in electromagnetism.
Is there some rule, so I don't do it wrong again.
In general I have noticed that when I have some vector integral it's not clear to me what I should choose as my boundary limits. Here is a couple of examples.


a) In the first exercise I need to find the induced EMF of a copper rod sliding along two rails next to long conducting wire (It is related to this post:How to calculate induced emf of moving rod?).
Calculating the induced EMF could be done with the following formula: $$\mathcal{E}=\oint(\overrightarrow{\boldsymbol{v}} \times \overrightarrow{\boldsymbol{B}}) \cdot d \vec{l}$$ Since it's only the copper rod which is moving, it becomes an simple line integral.
Let's say I choose my dL vector to point along the $x$-axis as showed. My integral would become:
$$\mathcal{E}=\int_{a}^{a+L}(\vec{v} \times \vec{B}(L)) \cdot d \vec{L}=\int_{a}^{a+L}(v \hat{k} \times B(L) \hat{\jmath}) \cdot d L \hat{i}=\frac{v \mu_{0} I}{2 \pi} \ln \left(\frac{a}{a+L}\right).$$
If I choose my dL-vector to point in the other direction (negative x), then I would assume I should integrate from a+L to a. Indeed this gives the same result:
$$\mathcal{E}=\int_{a+L}^{a}(\vec{v} \times \vec{B}(L)) \cdot d \vec{L}=\int_{a}^{a+L}(v \hat{k} \times B(L) \hat{\jmath}) \cdot d L (-\hat{i})=\frac{v \mu_{0} I}{2 \pi} \ln \left(\frac{a}{a+L}\right).$$

b) In the next exercise, it just doesn't work out changing the boundaries.
I need to calculate the magnetic force on the metal rod. In the previous exercise we found that the induced current (i) is counter clock wise.
We could calculate the magnetic force choosing the dL-vector pointing the same way as the current (see figure 2), using the following formula: $d \vec{F}=i d \vec{L} \times B(L)$
$$F_{M}=\int_{a}^{a+L} i d L(-\hat{\imath}) \times B(L) \hat{\jmath}=-i \frac{\mu_{0} I}{2 \pi} \ln \left(\frac{a+L}{a}\right) \hat{k}$$
Which indeed gives us an magnetic force in the right direction (negative z-direction). But why shouldn't I integrate along my $dL$-vector from $a+L$ to a instead, like I did in the exercise before? This gives the wrong result.

Another example is the following exercise. 

I need to calculate the $B$-field at point $P$.
When trying to calculate the $B$-field from the 3rd segment, I get confused over the boundary limits again.
The correct integral is:
$$\vec{B}(r)=\int_{0}^{\theta a} \frac{\mu_{0}}{4 \pi} \frac{I d \vec{L} \times \hat{r}}{a^{2}}=\int_{0}^{\theta a} \frac{\mu_{0} I}{4 \pi a^{2}} d L(-1) \hat{k}=-\frac{\mu_{0} I}{4 \pi a} \theta \hat{k}$$
Which indeed gives us an magnetic field in the negative $z$-direction as expected. But why shouldn't I integrate from $\theta a$ to $0$ along my $dL$-vector?
 A: In part a) the EMF is the voltage induced in the circuit, but it's best to view $\mathcal{E} = \oint (\mathbf{v}\times\mathbf{B})\cdot \mathrm{d}\mathbf{L}$ as giving you the magnitude of this voltage not its polarity. This is much like saying a battery provides 12 V of EMF, it doesn't tell you which way current flows. To make sure you have the direction the current flows correct you should always use the Lorentz force or Lenz's law. 
In part b) the direction along which you integrate is actually built in. Whereas in $\mathcal{E} = \oint (\mathbf{v}\times\mathbf{B})\cdot \mathrm{d}\mathbf{L}$,  $\mathrm{d}\mathbf{L}$ is along the direction of the path you choose, in $\mathrm{d}\mathbf{F}_M = I \mathrm{d} \mathbf{L} \times \mathbf{B}$, $\mathrm{d} \mathbf{L}$ is along the direction the current flows (since $I \mathrm{d} \mathbf{L} = q \mathrm{d}\mathbf{v}$). When we write something like $\mathrm{d}\mathbf{L} = \mathrm{d}L \hat{L}$, $\mathrm{d}L$ must increase in the direction of $\hat{L}$ to be consistent. So let the right end of the rod be $L_1=0$ and the left end be $L_2=L$. The path always goes from $L_1$ to $L_2$, since this is the direction current flows, i.e.
$\mathbf{F}_M = \int_{L_1}^{L_2} I \mathrm{d}\mathbf{L} \times \mathbf{B}(r) $
When you do a line integral, to be sure things are correct you really need to parametrize the path along which you're integrating. We could use a trivial parametrization like $L(x)=x$, where the path would be for $x=0$ to $x=L$. Then $\mathrm{d}L=dx$ and we have
$\mathbf{F}_M = -\int_0^L I B(r(x)) (\hat{i}\times\hat{j}) \mathrm{d}x $
where r(x) = a+L-x is the distance from the wire generating the B-field. If we insist on integrate from $a$ to $a+L$ we need to introduce a parametrization so that L(a) = 0 and L(a+L) = L. One parametrization that does the job is L(x) = x-(a+L). Then $\mathrm{d}L=dx$ and we have
$\mathbf{F}_M = \int_a^{a+L} I B(r(x)) (\hat{i}\times\hat{j}) \mathrm{d}x $
and r(x) = x. Both of these integrals give the correct answer. Note that if we insist on an integral from $a+L$ to $a$ we can choose the parametrization $L(x) = a+L-x$ and $\mathrm{d}L=-dx$.
Something similar happens with the third example you provide. Again $\mathrm{d}\mathbf{L}$ is along the direction the current flows, so take $\mathrm{d}\mathbf{L}=-\mathrm{d}L \hat{\theta}$, where $\hat{\theta}$ is define in the conventional way for polar coordinates. Insisting on integrating in along the current from $\theta=\theta_0$ to $\theta=0$ we need to find a parametrization of the path from $L(\theta_0)=L_1=0$ to $L(0)=L_2=a\theta_0$. The parametrization $L(\theta)=a(\theta_0-\theta)$ does the job and $\mathrm{d}L=-a\mathrm{d}\theta$ (note how the dimensions of the differential always match the dimensions of the limits of integration), so that
$\mathbf{B} = \int_{\theta_0}^0 \frac{\mu_0I}{4\pi a} \mathrm{d}\theta \hat{k}$
which is exactly what you have. 
In both the second and third examples the less careful calculations which give the right answer are ones whose limits correspond to a parametrization where $\mathrm{d}L \propto \mathrm{d}x$ and not $\mathrm{d}L \propto -\mathrm{d}x$, i.e. $L$ increases as the integration parameter $x$ increases instead of the opposite. Keeping track of extra minus signs is one reason you have to be so careful with line integrals.
So long story short, you can perform line integrals with whatever limits you like as long as you're careful and consistent. I hope this helps, let me know if you have any other questions.
