Express the maximum work from a voltaic cell The net cell reaction of an electrochemical cell and its standard potential is given below:
$$\ce{ Mg + 2Ag+ -&gt;Mg^{2+} + 2Ag} \ \ \ \ \ \ \ \ E^\circ=3.17\:\mathrm{V}$$ 
The question is to find the maximum work obtainable from this electrochemical cell if the initial concentrations of $\ce{Mg^{2+}}=0.1\ \mathrm{M}$ and of $\ce{Ag+}=1\ \mathrm{M}$. 

The solution just uses the Nernst equation to find the potential at this concentrations and uses $\Delta G=-nFE$ to calculate the Gibbs free energy change which is then equated to the maximum work obtainable. 

But this is just the work obtainable per mole at this concentration only. As soon as the reaction proceeds, the concentration change and so does the value of $\Delta G$ per mole and therefore the maximum work obtainable is different for different concentrations. 

Therefore, to find the maximum work obtainable, shouldn't we first calculate the equilibrium constant of this reaction (I calculated it to be $K_c=1.89\times10^{107}$), then the equilibrium concentrations(which is probably $\ce{Mg^{2+}}=0.6\ \mathrm{M}, \ \ce{Ag+}=0.178\times10^{-53}\ \mathrm{M}$) and then use something like:
$$
\int_{\mathrm{in}}^{\mathrm{eq}}\Delta G* \mathrm{d\,M}
$$ 
where $\Delta G$ is per mole and the $dM$ is a small amount in moles that the reaction proceeds at that concentration. 

Please help me verify my method and to proceed further.
There is a simpler approach to this problem.

First, since both initial concentrations are not 1 M, you need to determine $E$ for the initial conditions, where $Q$ is the reaction quotient $Q=\frac{[\ce{Mg^{2+}}]}{[\ce{Ag^{+}}]^2}$:

$$E=E^\circ-\dfrac{RT}{nF}\ln{Q}$$

The value of $n$ for this reaction is $n=2$, and assuming $T=298\ \mathrm{K}$:

$$E_i=3.17\ \mathrm(V)-\dfrac{(8.314 \dfrac{\text{J}}{\text{K}\cdot \text{mol}})(298 \text{ K})}{(2)(9.648\times10^4 \dfrac{\text{C}}{\text{mol}})}\cdot\ln{\dfrac{0.1 \text{ M}}{(1.0 \text{ M})^2}}=3.22 \text{ V}$$

You can then go and convert this potential into free energy or maximum work or whatever else you want. 

At equilbrium $E=0$ and $Q=K_c$, so we can calculate the equilibrium constant if we want to compare it to $Q$ and determine which direction is favored. We don't need to. Since $E_i&gt;0$, this reaction procedures toward the products.

Now, as the reaction proceeds the concentrations of $\ce{Ag+}$ and $\ce{Mg^{2+}}$ will change. From the law of mass action:

$$-\Delta \ce{[Ag+]}= 2\Delta \ce{[Mg^{2+}]}$$

After some time $\Delta \ce{[Ag+]} = 0.25 \text{ M}$, so $\Delta \ce{[Mg^{2+}]}=0.125\text{ M}$ and $[\ce{Ag+}]=0.75 \text{ M}$ and $[\ce{Mg{2+}}]=0.225 \text{ M}$. The value of $Q$ has changed and so has the value of $E$:

$$E_i=3.17\ \mathrm(V)-\dfrac{(8.314 \dfrac{\text{J}}{\text{K}\cdot \text{mol}})(298 \text{ V})}{(2)(9.648\times10^4 \dfrac{\text{C}}{\text{mol}})}\cdot\ln{\dfrac{0.225 \text{ M}}{(0.75 \text{ M})^2}}=3.18 \text{ V}$$

As the reaction proceeds, the value of $E$ decreases, which means the amount of work that can be done by the reaction also decreases. The maximum value of $E$ occurs at the initial state, and so the maximum work that this cell can do happens at the initial state. Since $E$ decreases as the reaction proceeds, so too does the work the cell can do at any moment.

If you want the total work, then you need to integrate with respect to $Q$, not worrying about the actual concentrations:

$$\int_{Q_i}^{K_c}E\cdot\mathrm{d}Q$$