Why Take Logarithms Before Differentiating?
An equation can involve the variable \(y\) both as a base and as an exponent. For example, in \(y^x=x^y\), neither side is an ordinary power with a constant exponent. If \(y\) depends on \(x\), both the base and exponent vary as \(x\) changes.
Taking natural logarithms turns variable powers into products. The resulting equation is usually easier to differentiate, although it still requires the product rule and the chain rule. The main task is to keep track of every occurrence of \(y\) as a function of \(x\), then solve the differentiated equation for \(dy/dx\).
Logarithms of Both Sides
For the real-valued logarithmic method used here, take \(x>0\) and \(y>0\). Then both sides of \(y^x=x^y\) are positive, and the natural logarithm is defined. Since \(\ln\) is one-to-one on the positive real numbers, taking logarithms preserves equivalence:
The last equivalence uses the logarithm rule \(\ln(a^b)=b\ln a\) for positive \(a\). Once the equation is written in this form, suppose \(y=y(x)\) is differentiable. Both \(x\) and \(y\) vary, so the product rule applies to each side.
The factor \(1/y\) in the first derivative comes from differentiating \(\ln y\) by the chain rule. The term \(y/x\) in the second derivative comes from differentiating \(\ln x\), while \(y\) is the other factor.
Deriving the Slope Formula
Equating the derivatives gives an equation that is linear in \(dy/dx\). Collect the terms containing \(dy/dx\) on one side:
If the coefficient \(x/y-\ln x\) is nonzero, division by that coefficient gives the slope. The condition matters: division by zero is not valid, and at a point where the coefficient vanishes this calculation does not determine \(dy/dx\).
This derivation also explains why the method works. On the positive domain, the logarithmic equation describes exactly the same relation as the original equation. Differentiating that equivalent relation gives a necessary equation for the slope of any differentiable solution \(y(x)\). Solving it yields the formula wherever its coefficient is nonzero.
Worked Examples
Worked Example: The Diagonal Solution at (2, 2)
Find the slope for a differentiable solution of \(y^x=x^y\) through \((2,2)\). First check the point in the original equation:
Thus the point satisfies the relation. Write \(m=dy/dx\) at the point and use the logarithmically transformed equation. At \(x=2,\ y=2\), the differentiated equation is
Rearrange and solve:
Since \(\ln 2\ne1\), divide by \(1-\ln 2\) to obtain \(m=1\). Check by substitution into the differentiated equation: its left side is \(\ln 2+1\), and its right side is \(\ln 2+1\), as required. In fact, \(y=x\) is a solution for every positive \(x\), and its derivative is \(1\).
Worked Example: Finding the Slope at (2, 4)
Find \(dy/dx\) for a differentiable solution through \((2,4)\). Check the original relation first:
The point lies on the curve. Let \(m=dy/dx\) there. Substituting \(x=2,\ y=4\) into the differentiated logarithmic relation gives
Use \(\ln 4=2\ln 2\), and write \(L=\ln 2\) temporarily to make the algebra easier to read:
Because \(1/2-\ln 2\ne0\), solve for \(m\):
To check, substitute this value into the equation for \(m\): multiplying the displayed expression for \(m\) by \(1/2-\ln 2\) gives \(2-2\ln 2\), exactly the right-hand side. The original differentiated equation is therefore satisfied. The slope is negative because \(2-2\ln 2>0\), while \(1/2-\ln 2<0\).
Worked Example: Finding the Slope at (4, 2)
Now find the slope at \((4,2)\). Verify that the point is on the relation:
Set \(m=dy/dx\). Substitution into the differentiated equation gives
Using \(\ln 4=2\ln 2\), rearrange to isolate \(m\):
The denominator is nonzero because \(\ln 2\ne1\). For the check, multiplying this value of \(m\) by \(2-2\ln 2\) gives \(1/2-\ln 2\), so the rearranged differentiated equation holds. Substituting back into the previous line gives equal left and right sides. This slope differs from the one at \((2,4)\), even though the two points exchange their coordinates.
When the Formula Cannot Be Used
The formula has a denominator, so it is not valid when \(x/y-\ln x=0\). At such a point, the differentiated relation becomes
This equation either creates a contradiction or gives no value for the slope; it cannot be solved by dividing by the zero coefficient. For example, at \((e,e)\), both sides of the slope equation are zero. The formula becomes \(0/0\), which is undefined. This calculation alone does not determine a slope there; a separate analysis of the local relation would be needed.
By contrast, at a diagonal point \((a,a)\) with \(a>0\) and \(a\ne e\), the numerator and denominator of the formula are both \(1-\ln a\), which is nonzero. The formula therefore gives \(dy/dx=1\), consistent with the solution \(y=x\). It is important to distinguish this case from \((e,e)\), where division by \(1-\ln a\) would mean division by zero.
A Common Mistake: Dropping a Product-Rule Term
A frequent error is to differentiate \(y\ln x\) as though \(y\) were constant. That misses the derivative of \(y\). The product rule gives
not just \(y/x\) or just \((dy/dx)\ln x\). For a concrete example, at \((2,4)\), omitting the term \(\ln 4\) on the left would incorrectly produce
That is not the correct equation: differentiating \(x\ln y\) also contributes \(\ln y=\ln 4\). The correct equation is
which gives \(m=(2-2\ln 2)/(1/2-\ln 2)\), not \(2/(1/2-\ln 2)\). The omitted term changes the answer, so writing each product-rule derivative before collecting terms is a useful safeguard.
A Reliable Calculation Order
Confirm that the proposed \(x,y\) satisfy the original equation and are positive so the logarithms are defined.
For \(y^x=x^y\), rewrite the equation as \(x\ln y=y\ln x\).
Use the product rule on both sides, and use the chain rule when differentiating \(\ln y\).
Collect the terms involving \(dy/dx\), verify the coefficient is nonzero before dividing, and substitute the result into the differentiated equation.
The same approach applies to other positive variable-power relations: take logarithms to expose the exponent as a factor, differentiate while treating \(y\) as a function of \(x\), and solve the resulting linear equation for \(dy/dx\) when its coefficient is nonzero. The exact logarithmic equation depends on the relation, so it should be written before differentiating rather than inferred from the final formula.
Check Your Understanding
For each question, keep the logarithmic transformation and the condition for division in view.
- Starting from \(y^x=x^y\) with \(x,y>0\), write the equivalent equation obtained by taking natural logarithms.
- Differentiate \(x\ln y=y\ln x\), treating \(y\) as a differentiable function of \(x\).
- At \((2,4)\), why must the term \(\ln 4\) appear when differentiating \(x\ln y\)?
- What condition allows the equation for \(dy/dx\) to be solved by division?
- Why does the formula give no slope at \((e,e)\)?