# How do you get substitution to recognize a derivative?

I have a simple expression involving a derivative:

x[t_] = Q/T[t];
Simplify[Derivative[1][x][t] /. Q -> x T[t]]

That produces:$$-\frac{x T'[t]}{T[t]}$$I have another relation: $$T=a^{-1}$$. When I make the substitution, I get this:

Simplify[-((x*Derivative[1][T][t])/T[t]) /. T[t] -> 1/a[t]]

$$-x a[t] T'[t]$$

But what I want is this: $$x \frac{a[t]}{a'[t]}$$I know I can force the issue with an additional substitution of $$T'[t]=-a'[t]^{-1}$$, but it seems to me that I've already given Mathematica everything it needs to make that substitution on it's own. How do I force MMa to recognize this kind of substitution in the derivative?

• Related: mathematica.stackexchange.com/a/67036/1871 There should be more. Mar 27, 2021 at 15:05
• I can't really follow any of your steps. First of all, if you want Derivative to take substitutions into consideration, then you probably need to make them before applying that function. Additionally, did you intend x and x[t] to be different? Mar 27, 2021 at 15:06
• I understand that I can go backwards in the derivation and make the substitution before I calculate the derivative, but that makes the derivation more confusing. I'd like to make the substitution in the last step so that it's very clear how I got to this point. Mar 27, 2021 at 15:12
• (1) Why x, which is treated like a number, instead of x[t] in your substitution? (= Marco’s question) (2) The syntax of Derivative[order][func][arg] requires that a function f be substituted for func, not an expression like f[t] that represents the value of a function. Mar 27, 2021 at 17:02

We can make the functional transformation via substitutions, without destroying the symbolic T[t] by giving it a definition, and the calculus will be done automatically:

x[t_] = Q/T[t];
Simplify[Derivative[1][x][t] /. Q -> X T[t]]
% /. T -> (1/a[#1] &)

One can change the X to x if desired. It seems undesirable from a programming point of view to have a definition of x as a function lurking while treating same symbol later as a different sort of object. If you want to switch between x being a dependent and independent variable, which I sometimes do when transforming differential equations, the following sequence of transformations avoids giving x a definition:

Derivative[1][x][t] /.
x -> (Q/T[#] &) /.
Q -> x T[t] /.
T -> (1/a[#1] &)

If I need to use transformations repeatedly, I might save each in a variable like x2T, Qsub, T2a.

• I'm having trouble understanding this intuitively. If $a$ is the inverse of $T$, then how did $a$ end up in the denominator? Just looking at the equation, it seems like the result should be $$\frac {x\space a[t]}{a'[t]}$$That is, how come we don't get the inverse of $\frac{T'[t]}{T[t]}$? Mar 27, 2021 at 21:02
• @Quarkly What do you mean by inverse, inverse function or reciprocal? If reciprocal, the derivative of $T[t]=1/a[t]$ is $T’[t]=- a’[t]/a[t]^2$ by the Chain and power rules. How would the derivative $a’[t]$ end up in the denominator if $T’[t]$ is in the numerator? The Chain rule never puts the derivative in the denominator. And the power rule puts an $a[t]^2$ in the denominator, which combines with the power of $a[t]$ from $T[t]$ in the denominator. (The inverse function theorem has a derivative in the denominator, though.) Mar 27, 2021 at 21:19
• I guess that should read 'reciprocal'. OK. I see it now. Thank you. Mar 27, 2021 at 21:22

You are making a mistake. If T[t] = 1/a[t] , then T'[t] = D[(1/a[t]), t] = -a'[t] / a[t]^2

Further, replacement is a wholly structural operation, it can not do derivatives. To achieve what you want, you would have to set T[t]= 1/a[t]

Clear[a, T]
T[t_] = 1/a[t];
x T'[t]/T[t]

• I get x a[t] Derivative[1][T][t] when I execute that statement. Still can't produce the negative sign. Mar 27, 2021 at 15:27
• Sorry, there was a typo, I corrected it: T[t_] instead of T[t] Mar 27, 2021 at 15:57
• Same question as below. If $T=\frac{1}{a}$, then how come the $a[t]$ term is still in the denominator of this result? I would expect the numerator and denominator to switch places when there's an inverse relation. Mar 27, 2021 at 21:05
• Look at the derivative of 1/a. Mar 27, 2021 at 21:10