9
$\begingroup$

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.

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

1 Answer 1

15
$\begingroup$

You can use the ResourceFunction "ChainD" for this purpose:

ResourceFunction["ChainD"][Log[f[x]],Log[x]]

(x f'[x])/f[x]

$\endgroup$
1
  • $\begingroup$ Thanks. Had not come across that (experimental) function before. Looks like there are lots of interesting things to play around with using it. $\endgroup$ Commented Oct 5, 2020 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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