Let's take a composite Mathematica command:
A[B[]]
where A
and B
- two arbitrary Mathematica commands and []
- inner object of arbitrary structure
What code to use to swap them, i.e.:
A[B[]]
$\xrightarrow{\text{?}}$B[A[]]
for example:
D[Sin[]]
$\xrightarrow{\text{?}}$Sin[D[]]
Let's also consider a more complicated case:
for expression D[Transpose[x] + Sin[x y], x]
we must get Transpose[D[x, x]] + Sin[D[x y, x]]