Let's say that I have
x^2+x
Is there a way to map $x$ to the first derivative of a function and $x^2$ to the second derivative of the same function? According to http://reference.wolfram.com/language/ref/Slot.html, I know that I can change
x /. x -> D[#, {y, 1}] &[a[y, z]]
x^2 /. x^2 -> D[#, {y, 2}] &[a[y, z]]
to yield the first and second derivatives of $a(y,z)$, respectively. I also know that I can use
x^2+x/. x^2 -> D[#, {y, 2}] &[a[y, z]] /. x -> D[#, {y, 1}] &[a[y, z]]
but if I have say, a polynomial of degree 70, manually telling Mathematica to do this is highly inefficient. Is there a method, such that, for $x^n$, I can tell Mathematica to map $x^n$ to the $n^{th}$ derivative of a function?
Answer
{x, x^2, x^2 + x} /. x^n_. :> Derivative[n, 0][a][y, z]
Comments
Post a Comment