-1
$\begingroup$

This question already has an answer here:

Mathematica's default way of representing derivatives is to express them with respect to a function's input slot. But what if I want to use the chain rule? To replace df(x)/dx with df(0.5 y)/dy 0.5, where x=2y. What is the Mathematica way of doing this? Is the proper way using [esc] pd [esc] [Ctrl][-][x]?

I'm following a quantum mechanics lecture and trying to write down the math on the slides to Mathematica. I just can't figure out how to express the steps in Mathematica code. I'm really struggling with the first slide of https://www.youtube.com/watch?v=DDvnybFrVlE&index=21&list=PLoRUNeJAicqZ_qLKTrdbXvvg_WTtFK_Ds

Apparently, the first step in solving a differential equation is often a change of variables, which he proceeds to do on the first slide. He uses the chain rule to change the variable that psi is differentiated with respect to.

$\endgroup$

marked as duplicate by xzczd, m_goldberg, Feyre, corey979, MarcoB Nov 21 '16 at 14:39

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ D[f[y/2], y]? It's not clear to me what code you're starting with and how you want to transform it. Well, that's what I'm assuming you want to do. $\endgroup$ – Michael E2 Nov 20 '16 at 18:03
  • $\begingroup$ There's also f'[x] /. f -> (f[#/2] &), but it keeps x instead of substituting y. $\endgroup$ – Michael E2 Nov 20 '16 at 18:05
  • 1
    $\begingroup$ Or are you merely asking how to input D via a shortcut, which is described in the first bullet point under "Details and Options" section of the docs for D? $\endgroup$ – Michael E2 Nov 20 '16 at 20:38
0
$\begingroup$

WL provides two basic ways to produce derivations: derivatives of functions w.r.t. slots (uinsg Derivative), and derivatives of expressions with respect to variables (using D). The shorthand you mention is for D, so just use it with an expression you are interested in, and the chain rule will be applied automatically. E.g.,

In[]:= Clear[f, g]; D[g[f[x]], x] /. {x -> x0}

Out[]= Derivative[1][f][x0] Derivative[1][g][f[x0]]

(where the space is implicit times).

$\endgroup$

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