The net cell reaction of an electrochemical cell and its standard potential is given below: $$\ce{ Mg + 2Ag+ ->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.