Multivariable Calculus Chain Rule

I am getting ready to write a notebook for the chain rule in Multivariable Calculus for my students. I do know:

Clear[x, y, z, t];
x = 2 t^2;
y = 3 - t^3;
z = x^2 + y^2;
D[z, t]


Or:

Clear[x, y, z, u, v];
x[u_, v_] = u^2 + v^2;
y[u_, v_] = u^2 - v^2;
z[x_, y_] = x^2 + y^2;
D[z[x[u, v], y[u, v]], v]


But do folks have other suggestions and/or examples?

For example, might someone show that if $f(x)=x^2+y^2$ and $x=u^2-uv+v^2$ and $y=u^2+2uv-3v^2$, then the answer for $\partial f/\partial u$ is held to $(2x)(2u-v)+(2y)(2u+2v)$, which would help students with their intermediate steps.

And I think there are some that like to use Dt to do the chain rule?

Update

Just getting ready to teach the chain rule and although the Alexei Boulbitch example in the answer works:

Clear[x, y, u, v, f];
x = u^2 - u*v + v^2;
y = u^2 + 2 u*v - 3 v^2;
f = x^2 + y^2;
D[f, u] /. {x -> X, y -> Y}

(*  2 (2 u - v) X + 2 (2 u + 2 v) Y  *)


But this does not:

Clear[x, y, f, t]
x = 2 t;
y = t^2;
f = x^2 y + x y^2;
D[f, t] /. {x -> X, y -> Y}

(* 16 t^3 + 10 t^4 *)


Wondering what is the difference between this and the Alexei Boulbitch answer, which works.

I am not really sure that I understand your aim, but as to the simple example in the end of your question, this seems to do the job:

    Clear[x, y, u, v, f];
x = u^2 - u*v + v^2;
y = u^2 + 2 u*v - 3 v^2;
f = x^2 + y^2;
D[f, u] /. {x -> X, y -> Y}

(*  2 (2 u - v) X + 2 (2 u + 2 v) Y  *)


Have fun!

Later comment: To address your later question: In the first example the trick worked, since the expressions of the result:

    Clear[x, y, u, v, f];
x = u^2 - u*v + v^2;
y = u^2 + 2 u*v - 3 v^2;
f = x^2 + y^2;

D[f, u]

(*
2 (2 u + 2 v) *(u^2 + 2 u v - 3 v^2)* + 2 (2 u - v) *(u^2 - u v + v^2)*
*)


already contained the combinations exactly equal to x and y. I pointed them out by the asterixes in the answer. This enables one to directly apply the replacement. Your new example is different. If you make the calculation:

 Clear[x, y, f, t]
x = 2 t;
y = t^2;
f = x^2 y + x y^2;
D[f, t]

(*  16 t^3 + 10 t^4   *)


the result has no such a form as the previous one, and even more, one can represent its terms in many different ways as some products of x and y. One should decide, what he wants to achieve. What about the following:

 Clear[x, y, f, t]

f = x[t]^2 y[t] + x[t] y[t]^2;
Factor /@ (D[f, t] // Collect[#, {y'[t], x'[t]}] &)

(*  y[t] (2 x[t] + y[t]) Derivative[1][x][t] +
x[t] (x[t] + 2 y[t]) Derivative[1][y][t]   *)


?? Is it not closer to the chain rule?

If this is not what you are after, explain me please your target in more details.

Have fun!

• Nice example, just the type of thing I am looking for. Interesting approach. – David Jul 17 '15 at 17:14
• Just did an update to my post and wondering why your technique does not work this time. – David Oct 15 '15 at 5:40
• @David Please have a look into the edit. – Alexei Boulbitch Oct 19 '15 at 8:09
• Alexei, thanks for the help. :-) – David Oct 20 '15 at 15:38