3
$\begingroup$

I wanted to ask a question about implicit differentiation in partial differentiation.

When I was at school, I remember partial differentiation as something like this:

When you have a function composed of $x$ and $y$'s and you run into a $y$ term, differentiate with respect to $y$ and multiply by $\frac{dy}{dx}$ i.e. $$\frac{d}{dx} = \frac{d}{dy} \times \frac{dy}{dx}$$

Now, I read a problem on the Physics section yesterday afternoon that is relevant to my Chemistry course and I couldn't work it out.

If I have the equation

\begin{aligned} \frac{F\left(N_{A}, N_{B}\right)}{k T}=& N_{A} \ln \left(\frac{N_{A}}{N}\right)+N_{B} \ln \left(\frac{N_{B}}{N}\right) \\ &+\left(\frac{z w_{A A}}{2 k T}\right) N_{A}+\left(\frac{z w_{B B}}{2 k T}\right) N_{B}+\chi_{A B} \frac{N_{A} N_{B}}{N} \end{aligned}

I can get a quantity called the Chemical potential $\mu_{A}$ by differentiating the above equation with respect to $N_A$ while keeping $N_B$ and $T$ constant.

$$\mu_{A}=\left(\frac{\partial F} {\partial N_{A}}\right)_{T, N_{B}}$$

(The above equation is called the Free Energy Equation)

$N$ is the total number of molecules in the system, $N_A$ and $N_B$ are the number of molecules of A and B respectively. $N$ is not constant. They are related quite simply as via the sum:

$$N = N_A + N_B$$

which makes sense.

This equation also shows us that a small change in $N_A$ will also yield a small change in $N$ hence why $N$ is not constant, as mentioned above.

So I wanted to get from this equation, $\mu_{A}$

$$\frac{\mu_{A}}{k T}=\left[\frac{\partial}{\partial N_{A}}\left(\frac{F}{k T}\right)\right]_{T, N_{B}}$$

which makes sense.

The result given from the book (page 7), however, confused me. They gave the result as

$$=\ln \left(\frac{N_{A}}{N}\right)+1-\frac{N_{A}}{N}-\frac{N_{B}}{N}+\frac{z w_{A A}}{2 k T}+\chi_{A B} \frac{\left(N_{A}+N_{B}\right) N_{B}-N_{A} N_{B}}{\left(N_{A}+N_{B}\right)^{2}}$$

and only the last two terms made sense.

The OP asked where the terms

$$-\frac{N_{A}}{N}-\frac{N_{B}}{N}$$

came from and the answer given was as follows:

You missed the $N$ in the logarithm. Since $N_{B}$ is kept constant while changing $N_{A}$, the total number of particles $N=N_{A}+N_{B}$ changes as well. The missing term is $$\dfrac{\partial N}{\partial N_{A}}\dfrac{\partial}{\partial N}\left[N_{A}\ln\left(\dfrac{N_{A}}{N}\right)+N_{B}\ln\left(\dfrac{N_{B}}{N}\right)\right]=-\dfrac{N_{A}}{N}-\dfrac{N_{B}}{N}$$

and in the comments the value of $\dfrac{\partial N}{\partial N_{A}}$ was clarified to be $1$, again using the equation $N = N_A + N_B$. I understood this step.

but I then thought, if that was the case, how did the terms $$\ln \left(\frac{N_{A}}{N}\right)+1$$ arise then?

My original thought, similar to the OP was to differentiate:

$$\dfrac{\partial}{\partial N_{A}}\left[N_{A}\ln\left(\dfrac{N_{A}}{N}\right)+N_{B}\ln\left(\dfrac{N_{B}}{N}\right)\right]$$

but as explained, this assumed $N$ was constant, which it is not.

How are the terms $$\ln \left(\frac{N_{A}}{N}\right)+1$$

yielded by this application of implicit differentiation, if $\dfrac{\partial N}{\partial N_{A}} = 1$ using $\dfrac{\partial N}{\partial N_{A}}\dfrac{\partial}{\partial N}$?

$\endgroup$
  • $\begingroup$ You can easily achieve those terms by differentiating $N_A \ln (N_A/N)$ with respect to $N_A$ $\endgroup$ – user673903 May 25 at 0:15
3
+100
$\begingroup$

We want to compute \begin{aligned} \frac{\partial }{\partial N_A}\left( N_{A} \ln \left(\frac{N_{A}}{N}\right)+N_{B} \ln \left(\frac{N_{B}}{N}\right) +\left(\frac{z w_{A A}}{2 k T}\right) N_{A}+\left(\frac{z w_{B B}}{2 k T}\right) N_{B}+\chi_{A B} \frac{N_{A} N_{B}}{N}\right) \end{aligned}

First note that $$\frac{\partial N }{\partial N_A}= \frac{\partial}{\partial N_A}(N_A+N_B)=1+0=1$$

Now, let's compute partial derivative term by term.

\begin{align}\frac{\partial}{\partial N_A}\left(N_A\ln \left( \frac{N_A}{N}\right) \right) &= \left( \frac{\partial N_A}{\partial N_A}\right) \ln \left( \frac{N_A}{N}\right) + N_A \frac{\partial }{\partial N_A}\left( \ln \left( \frac{N_A}{N}\right)\right)\\ &= \ln \left( \frac{N_A}{N}\right) + N_A \frac{\partial }{\partial N_A}\left( \ln N_A - \ln N \right) \\ &=\ln \left( \frac{N_A}{N}\right)+ N_A (\frac1{N_A}-\frac1N \frac{\partial N}{\partial N_A})\\ &= \ln \left( \frac{N_A}{N}\right)+1-\frac{N_A}{N}\tag{1}\end{align}

where in the first line I have used product rule; in the second line, I have used a logarithm identity; in the third line, I used chain rule.

\begin{align}\frac{\partial}{\partial N_A}\left(N_B\ln \left( \frac{N_B}{N}\right) \right) &= \frac{\partial}{\partial N_A}\left(N_B(\ln \left( N_B)- \ln(N)\right) \right)\\ &= N_B(-\frac1N \frac{\partial N}{\partial N_A})\\ &=- \frac{N_B}{N}\tag{2}\end{align}

\begin{align}\frac{\partial}{\partial N_A}\left(\left(\frac{zw_{AA}}{2kT}\right)N_A\right) =\left(\frac{zw_{AA}}{2kT}\right)\tag{3}\end{align}

\begin{align}\frac{\partial}{\partial N_A}\left(\left(\frac{zw_{BB}}{2kT}\right)N_B\right) =0\tag{4}\end{align}

\begin{align}\frac{\partial}{\partial N_A}\left(\chi_{AB}N_B\left(\frac{N_A}{N}\right)\right) &= \chi_{AB}N_B\left(\frac{N-N_A \frac{\partial}{\partial N_A}N}{N^2} \right) \\&=\chi_{AB}\left(\frac{N_B}{N}\right)^2\tag{5}\end{align}

We just have to sum these terms up to get the result. Equation $(1)$ is of particular interest to you.

$\endgroup$
2
$\begingroup$

You're right that $N$ is not a constant; in fact, it's shorthand for a function $N(N_A, N_B) = N_A + N_B$.

$N$ is substituted for convenience. If you want to differentiate the expression $F/kB$ with respect to $N_A$, one option is to replace $N$ with $N_A+N_B$ wherever it occurs. $N$ is defined to be $N_A+N_B$ so this replacement is always okay, and when you differentiate the overall substituted expression with respect to $N_A$, you will get the right answer.

The full expression, with substitution, is:

$$\begin{aligned}F(a,b)/kB = & a \ln \left(\frac{a}{a+b}\right)+b \ln \left(\frac{b}{a+b}\right) \\ &+\left(\frac{z w_{A A}}{2 k T}\right) a+\left(\frac{z w_{B B}}{2 k T}\right) b+\chi_{A B} \frac{ab}{a+b} \end{aligned}$$

which consists of five terms. You can differentiate each of them separately with respect to $a$ then add up the results. For example, you can work out that the derivative of the first term is $\frac{b}{a+b} + \ln \left(\frac{a}{a+b}\right)$ and the derivative of the second term is $\frac{-b}{a+b}$.

Added together, these two terms give you $$\ln(\frac{a}{a+b}).$$ Actually this is equal to the first four mysterious terms $\ln(N_A/N)+1 - N_A/N - N_B/N$ in your answer—note that the four terms are actually simpler than they appear because the last three cancel:

$$1 - \frac{N_A}{N} - \frac{N_B}{N} = 1 - \frac{N_A+N_B}{N} = 1 - \frac{N}{N} = 1 - 1 = 0$$

so those four mysterious terms are equivalent to simply

$$\ln\left(\frac{N_A}{N}\right)$$


Instead of using the substitution route, you can also just apply the chain rule. Done properly, this must give you the same result.

Let's try it just on a simple term like $\ln(N_A/ N)$. We have:

$$\begin{align*}\partial_a \ln\left(\frac{a}{n}\right) &= \frac{1}{a/n} \cdot \partial_a \frac{a}{n} & \text{\{chain rule for ln\}}\\ &= \frac{1}{a/n} \cdot \frac{\partial_a(n)a - \partial_a(a)n}{n^2}&\text{\{quotient rule\}}\\ &= \frac{1}{a/n} \cdot \frac{1\cdot a - 1\cdot n}{n^2}\\& = \frac{n}{a}\frac{a-n}{n^2} \\&= \frac{1}{a}\frac{a-n}{n} \\&= \frac{1}{a}\frac{a}{n} - \frac{1}{a}\frac{n}{n} \\&= \frac{1}{n} - \frac{1}{a}\end{align*}$$

So when we compute the derivative of a more complex term like $N_A\ln(N_A/N)$, the product rule says that this is:

$$N_A \cdot \partial_{N_A} \ln\left(\frac{N_A}{N}\right) + \partial_{N_A}[N_A] \cdot \ln\left(\frac{N_A}{N}\right) $$ $$=N_A\left(\frac{1}{N} - \frac{1}{N_A}\right) + 1\cdot \ln\left(\frac{N_A}{N}\right) = \left(\frac{N_A}{N}-1\right) + \ln\left(\frac{N_A}{N}\right)$$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.