Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have two functions x = x(u,v) and y = y(u,v). The chain rule says that for a function f(x,y), df/dx = df/du du/dx + df/dv dv/dx, and similarly df/dy = df/du du/dy + df/dv dv/dy.

How do I get Mathematica to give me df/dx in terms of u, v, and df/du, df/dv?

I should point out that x(u,v) and y(u,v) are not easily invertible to give u(x,y) and v(x,y).

share|improve this question
add comment

1 Answer

You need to solve the linear system $$\begin{align} {\partial f \over \partial u}& = {\partial f \over \partial x} {\partial x \over \partial u} + {\partial f \over \partial y} {\partial y \over \partial u} \\ {\partial f \over \partial v}& = {\partial f \over \partial x} {\partial x \over \partial v} + {\partial f \over \partial y} {\partial y \over \partial v} \\ \end{align}$$ which can be done in Mathematica like this:

Solve[D[f[x[u, v], y[u, v]], {{u, v}}] == {dfdu[u, v], dfdv[u, v]},
   {Derivative[1, 0][f][x[u, v], y[u, v]], Derivative[0, 1][f][x[u, v], y[u, v]]}]

Here ${\partial f / \partial u}$, ${\partial f /\partial v}$ are represented by dfdu and dfdv. One problem with Leibniz' notation is that symbols are treated simultaneously as variables and as functions, which I've found difficult to do in programs like Mathematica. It's best to do it all in terms of functions in this case. For instance, Derivative[1, 0][f] represents ${\partial f / \partial x}$. However, in the expression ${\partial f / \partial u}$, $f$ represents the composition of $f(x,y)$ with $x(u,v)$ and $y(u,v)$, and the partial derivative is a derivative of the composition. In Mathematica you do that explicitly: compose the functions and differentiate. The system solved by Solve above is the same as

D[f[x[u, v], y[u, v]], u] == dfdu[u, v]
D[f[x[u, v], y[u, v]], v] == dfdv[u, v]

which makes dfdu, dfdv equivalent to the partial derivatives with respect to u, v. The output is a bit messy:

System solution

If you like you can clean up the look by using Format to make Mathematica write in the output in Leibniz' notation - if you really want to see the output in that sort of form. (Beware: Using Format this way can get you confused if your intention is to continue working with the output. At least it can get me confused.)

Format[Derivative[1, 0][f][args__]] := Row[{"\[PartialD]", f}]/Row[{"\[PartialD]", x}]; 
Format[Derivative[0, 1][f][args__]] := Row[{"\[PartialD]", f}]/Row[{"\[PartialD]", y}]; 
Format[dfdu[args__]] := Row[{"\[PartialD]", f}]/Row[{"\[PartialD]", u}]; 
Format[dfdv[args__]] := Row[{"\[PartialD]", f}]/Row[{"\[PartialD]", v}]; 
Format[Derivative[1, 0][g : x | y][args__]] := Row[{"\[PartialD]", g}]/Row[{"\[PartialD]", u}];
Format[Derivative[0, 1][g : x | y][args__]] := Row[{"\[PartialD]", g}]/Row[{"\[PartialD]", v}];

Solve[D[f[x[u, v], y[u, v]], {{u, v}}] == {dfdu[u, v], dfdv[u, v]},
   {Derivative[1, 0][f][x[u, v], y[u, v]], Derivative[0, 1][f][x[u, v], y[u, v]]}]

Formatted output

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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