Find the work to move a coil in an uniform magnetic field we have a rectangular coil ($d$ and $3d$ wide) in a magnetic field as in the picture.

To the left we have $B_0 T$ and to the right $\frac{B_0}{2} T$.
There is a counterclockwise current in the coil of $i_0 A$.

*

*Find the work to move the coil to the right region.

*Find the work to move the coil to the left region.

This is a homework text and i coundn't find the solution on internet.
Considering the first point; as long as I know to calculate the work i need the distance and the force. As you can see there's a net force to the left since the MF is greater to the left, so if I apply an equal net force in magnitude but opposite in direction i should find the coil to be static in space. However: if i apply a force that is a little bigger to the right, the coil should move to the right and i can calculate the mechanical work since i know the distance and force. But i can apply so many different forces to the right that i can even have a infinite work if i apply an infinite force.
I do not know if this problem makes sense but since i found it i wanted to have an answer. How much is this work?
 A: It sounds like you're essentially there.
The simplest way to solve this is with the Lorentz force law, $d\vec{F} = I d\vec{l}\times \vec{B}$. In the situation sketched, where moving the loop changes the magnetic flux, you have
$F_{net} = \oint d\vec{F} = -I_0[B_0 L - \frac{B_0}{2} L] = -\frac{1}{2}B_0I_0L_0$ directed rightwards.
The key insight here comes from looking at the top and the bottom wires. At each point, they see equal magnetic field with equal and opposite currents, so (assuming a rigid coil) their net contribution is zero.
Once the loop is fully inside the homogeneous left hand or right hand region, the same applies to the left and right wires - equal and opposite currents, zero net force. You only have to integrate the force until the loop leaves the interface region, then no more work needs to be done.
Getting the same thing from Maxwell's equations (handy if the field or wire shape is wonky)
If you're into vector calc, you can also view this (a little more strenuously) as an application of Faraday's law,
$$-\frac{\partial \Phi_B}{\partial t}=-\frac{\partial}{\partial t} \iint B dA = \oint E dl$$
Let the loop have width $2w$, area $A$.
Suppose we move the loop on a 3D path $\mathbf{r}(t) = (x(t), y(t), z(t))$, where $\mathbf{r}=0$ means the loop is centred as in the diagram. This causes a time dependent magnetic flux $\Phi_B(t) = \begin{cases} -B_0A & x < -w\\ -\frac{B_0A}{2}(1 - \frac{x(t)}{w}) & -w < x < 2 \\ -\frac{B_0A}{2} & x>w \end{cases}$.
In the interesting $-w<x<w$ region, $-\frac{dB}{dt} = -\frac{B_0 A}{2w}x'(t)$.
This raises the question of who is doing the work, and how. This subtlety is hidden in the seemingly innocuous condition

There is a counterclockwise current in the coil of $I_0 A$.

Ignoring resistance, a loop of ideal wire going through this motion will have the current going around it changed as it moves into a region of different magnetic field. (When it's left fixed, the current will just circulate forever). To maintain constant current, we need to do work against the induced electric field to maintain the fixed $I_0$.
The electrical power this takes per unit time is
$$\frac{dW}{dt} = VI_0 = \oint E\cdot dl I_0 = -\frac{B_0 I_0 A}{2w}x'(t)$$
When moving the loop left to right (by any path), the energy cost we have to pay is then
$$\int \frac{dW}{dt}dt = \frac{B_0 A}{2w} \int x'(t) dt = \frac{B_0 A}{2w} \int_{-w}^w dx = B_0 I_0 A$$
in the appropriate units. (Watts, I think, if you use Tesla, Ampere and m$^2$)
