# How to do implicit differentiation in Mathematica?

I have an equation which is

K^(1/2)*L^(1/2)-(K+L) = 24


but I don't know how to do implicit differentiation to find dK/dL because I only know how to do the normal differentiation and the partial one.

Can anyone help? Thanks much!

• Have a look at Dt. – b.gates.you.know.what Aug 20 '16 at 15:26
• Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 Aug 20 '16 at 15:56
• – Michael E2 Aug 20 '16 at 17:44

Dt[], the total derivative, does what you're looking for.

Dt[K^(1/2)*L^(1/2)-(K+L)==24,L]

-1+Sqrt[K]/(2 Sqrt[L])-Dt[K,L]+(Sqrt[L] Dt[K,L])/(2 Sqrt[K])==0

Solve[%,Dt[K,L]]

{{Dt[K,L]->(Sqrt[K] (Sqrt[K]-2 Sqrt[L]))/((2 Sqrt[K]-Sqrt[L]) Sqrt[L])}}

• would you also use Dt to handle a derivative of a piecewise function that has some part that is defined by a numerical approximation (FindRoot) and so in order to take the derivative we would require to use the implicit function theorem for that part? Like in here:mathematica.stackexchange.com/questions/165472/… – Laura K Feb 9 '18 at 15:32

With k = k(L) we can write:

f[L_, k_] = Sqrt[k] Sqrt[L] - (k + L) - 24;
df = -D[f[L, k], L]/D[f[L, k], k] // Simplify


To do this, you must use k as a function of L. Where it's wise to use lower case k.

Note that K is a default generic name for a summation index in a symbolic sum.

eqn = k[L]^(1/2)*L^(1/2) - (k[L] + L) == 24
Solve[D[eqn, L], k'[L]]


{{Derivative[1][k][L] -> ((2 Sqrt[L] - Sqrt[k[L]]) Sqrt[k[L]])/( Sqrt[L] (Sqrt[L] - 2 Sqrt[k[L]]))}}

Here is a simple method I use. The following module performs implicit differentiation of an equation of two variables in a conventional format, i.e., with independent variable of the form x (or some other symbol), and dependent variable of the form y (or some other symbol). It converts the dependent variable to the form f [x] and calculates the derivative f' [x] if it exists, and then converts the symbols back to the input format and outputs the solution.

implicitD[lhs_, rhs_, indVar_, depVar_] :=
Module[{ls, rs, f, R},
ls = lhs /. depVar -> f[indVar];
rs = rhs /. depVar -> f[indVar];
R = Solve[D[ls, indVar] == D[rs, indVar], f'[indVar]][[1, 1]];
R /. {f[indVar] -> depVar, f'[indVar] -> depVar'}
]


For example, to differentiate 3(x^2 + y^2)^2 == 100 x y, use module as follows:

implicitD[3(x^2 + y^2)^2, 100 x y, x, y]


Returns:

y' -> (-3x^3 + 25y - 3x y^2)/(-25x + 3x^2 y + 3y^3)

For your question: differentiate: K^(1/2)*L^(1/2) - (K + L) Use the same method:

implicitD[K^(1/2)*L^(1/2) - (K + L), 24, L, K]


Your result should look like this image: