# Can Mathematica do this derivative?

The definition of the elasticity (used in economics a lot) of a function f(x) is $$\frac{\mathrm{d} \log(f(x))}{\mathrm{d} \log(x)}$$. Using the chain rule, it is easy to show that:

$$\frac{\mathrm{d} \log(f(x))}{\mathrm{d} \log(x)} =\frac{\mathrm{d}\log(f(x))}{\mathrm{d}f(x)}\frac{\mathrm{d}f(x)}{\mathrm{d}x}\frac{\mathrm{d}x}{\mathrm{d}\log(x))} =\frac{x}{f(x)}\frac{\mathrm{d}f(x)}{\mathrm{d}x}$$

I couldn't find a way to input the derivative directly into Mathematica though. Is there a way?

Dt[ Log[ f[x] ], Log[x] ]


almost works, but not quite.

• Possible duplicate: mathematica.stackexchange.com/a/27393/4999 – Michael E2 Oct 5 '20 at 18:28
• A somewhat more direct coding of the formula works: Dt[Log[f[x]]]/Dt[Log[x]]. – Michael E2 Oct 5 '20 at 18:30
• That is an excellent tip Michael E2. Thank you very much. – OutsideLoop Oct 5 '20 at 19:40
• In:= D[Log[f[Exp[y]]], y] /. y -> Log[x] Out= (x Derivative[f][x])/f[x] also handles this. – Daniel Lichtblau Oct 6 '20 at 14:05
• This also works: Dt[Log[f[x]], Log[x]] /. x -> E^Hold[Log[x]] // ReleaseHold  . – Akku14 Oct 9 '20 at 13:37

You can use the ResourceFunction "ChainD" for this purpose:
ResourceFunction["ChainD"][Log[f[x]],Log[x]]