# Determinating the correct order of each endpoint of integration to make a result of calculation as correct one (positive or negative)

I think that the title is one of the general ones and I handle it with the below simple problem.

I made the own problem and the answer with the below diagram.

The finite length wire exists and the current flows from to upward like as the diagram.

We want to know the magnitude of the magnetic field which is generated at the point P.

$$~l,~\theta_{1},~I~\leftarrow~~\text{constants}$$

$$H= -\frac{ I }{ 4 \pi l } \int \sin\left(\theta_{} \right) d\theta ~~ \leftarrow~~ \text{magnetic field at point P}$$

The current problem for me is the order of the start angle and the end angle in the integration.

$$\frac{\pi}{2} ~,~ \theta_{1}~ ~~ \leftarrow~~ \text{angles of endpoints of the integration}$$

Of course the point P must take a positive magnitude of the magnetic field.

CASE1

$$H= -\frac{ I }{ 4 \pi l } \int_{\theta_{1} }^{ \frac{\pi}{2} } \sin\left(\theta_{} \right) d\theta ~~ \leftarrow~~ \text{magnetic field at point P}$$

$$= -\frac{ I }{ 4 \pi l } \bigl[ -\cos\left(\theta_{} \right) \bigr]_{\theta_{1}}^{\frac{\pi}{2} }$$

$$= \frac{ I }{ 4 \pi l } \bigl[ \cos\left(\theta_{} \right) \bigr]_{\theta_{1} }^{\frac{\pi}{2} }$$

$$= \frac{ I }{ 4 \pi l } \left( -\cos\left(\theta_{1} \right) \right) < 0$$

But as the order is inverse,

$$H= \frac{ I }{ 4 \pi l } \bigl[ \cos\left(\theta_{} \right) \bigr]_{\frac{\pi}{2} }^{\theta_{1} }$$

$$= \frac{ I }{ 4 \pi l } \cos\left(\theta_{1} \right) >0$$

How can I determine the correct order before doing the computation?

$$dH= \frac{ I }{ 4 \pi } \cdot \frac{ ds \cdot \sin\left(\theta_{} \right) }{ r ^{2} } ~~ \leftarrow~~ \text{general formula}$$

$$\sin^{}\left(\theta_{} \right) = \frac{ l }{ r } ~~\Leftrightarrow~~ \frac{ \sin^{}\left(\theta_{} \right) }{ l }= \frac{ 1 }{ r }$$

$$\tan \left( \theta_{} \right) = \frac{ l }{ s }$$

$$s= \frac{ l }{ \tan \left( \theta_{} \right) }$$

$$\frac{ ds }{ d\theta }= l \cdot \left( \tan \left( \theta_{} \right) ^{-1} \right) '$$

$$= l \cdot \left( -1 \right) \cdot \tan^{-2} \left ( \theta_{} \right) \left( \tan \left( \theta_{} \right) ' \right)$$

$$=\frac{ -l }{ \tan^{2} \left( \theta_{} \right) }\cdot \frac{ 1 }{ \cos^{2}\left(\theta_{} \right) }$$

$$= -l \cdot \frac{ \cos^{2}\left(\theta_{} \right) }{ \sin^{2}\left(\theta_{} \right) } \cdot \frac{ 1 }{ \cos^{2}\left(\theta_{} \right) }$$

$$= \frac{ -l }{ \sin^{2}\left(\theta_{} \right) }$$

$$\therefore ~~ ds=\frac{ -l \cdot d\theta }{ \sin^{2}\left(\theta_{} \right) }$$

$$\therefore ~~ dH= \frac{ I }{ 4 \pi } \cdot \frac{ ds \cdot \sin^{}\left(\theta_{} \right) }{ 1 } \cdot \frac{ \sin^{2}\left(\theta_{} \right) }{ l ^{2} }$$

$$= \frac{ I }{ 4 \pi } \cdot \frac{ \sin^{3}\left(\theta_{} \right) }{ l ^{2} } \cdot \left( \frac{ -l \cdot d\theta }{ \sin^{2}\left(\theta_{} \right) } \right)$$

$$=- \frac{ I }{ 4 \pi } \cdot \frac{ \sin^{}\left(\theta_{} \right) \cdot l \cdot d\theta }{ l ^{2} } = -\frac{ I }{ 4 \pi } \cdot \frac{ \sin^{}\left(\theta_{} \right) d\theta }{ l } =-\frac{ I }{ 4 \pi l } \cdot \sin^{}\left(\theta_{} \right) d\theta$$

• In you first equation for $H$ where does the minus sign come from? Jul 22, 2021 at 7:08
• I added the derivations. Jul 22, 2021 at 8:39

The problem that you have is that the very first integral lacks limits Let the current flow from A to B, so the limits are A to B. The element $$ds$$ points along the current, so your equation for $$s=l \cot \theta$$ is wrong because it increases the wrong way. You could define $$s$$ as the distance from A which is $$s=l(\cot \theta_1 - \cot \theta)$$. This gives the opposite sign to $$ds$$ as required.

This is not the only consistent way of setting up the problem, but yours is not consistent.

• Sorry , I can't get your meaning of "because it increases the wrong way". Can you tell me more detailed thing? Jul 24, 2021 at 1:31
• @bostondynamicslover If we write $s=l\cot\theta$ then $s=0$ is at the foot of the perpendicular from P, that is point B, and $s$ is positive at A. So it increases from B to A, but the current flows from A to B. So if you integrate from A to B, $ds$ is a negative quantity which invalidates your equation for $dH$. Is this clearer?
– CWPP
Jul 24, 2021 at 13:28

Reversing the limits of an integral simply changes the sign.

In this particular case, to find out the direction of the magnetic field (what H>0 and H<0 actually mean), use the right hand rule. With the thumb pointing in the direction of the current, your fingers go into the page, away from the observer, which is the direction of the field. So if we label that axis direction negative then H<0, and if we label that direction positive then H>0.

More generally in a physics problem, other problems perhaps where it isn’t a righthand rule determination: to decide which is the upper and which is the lower limit, considering one infinitesimal step along the way can help. But usually the signs are determined by understanding the physical situation, as in this case.