# Directional derivative of a function of three variables

I'm a Mathematica beginner and I'm and struggling with a problem concerning heat flow, not sure how to set it up with three variables. Any help with what I should input into Mathematica will be much appreciated.

Experiments show that in a temperature field, heat flows in the direction of maximum decrease of temperature $$T$$. Find this direction in general and at the point $$(2, -1, 2)$$ for $$𝑇(𝑥, 𝑦, 𝑧) = 𝑥^2 + 𝑦^2 + 4𝑧^2$$.

• Try taking the gradient and flipping the sign: -D[x^2 + y^2 + 4 z^2, {{x, y, z}}] /. Thread[{x, y, z} -> {2, -1, 2}] or similarly -Grad[x^2 + y^2 + 4 z^2, {x, y, z}] /. Thread[{x, y, z} -> {2, -1, 2}]. For directional derivatives there is ResourceFunction["DirectionalD"] Nov 23 '20 at 22:35
• i tried this and mathematica won't recognize my function having three variables, z is still in blue unlike x and y Nov 23 '20 at 23:47
• I'm guessing you wrote -D[x^2 + y^2 + 4 z^2, {x, y, z}] which is wrong. You need {{x,y,z}} with double braces, or just use Grad. Otherwise you need to post what you tried. If you are using a function: T[x_,y_,z_]:=x^2 + y^2 + 4 z^2; -Grad[T[x,y,z],{x,y,z}] Nov 24 '20 at 0:05

Here we use Mathematica to verify that the -Grad satisfy the maximum decrease.

the result1 according to the definition of derivative along a vector v.

Now it is equal to result2 or result3 means that the direction derivative is equal to $$\nabla T\bullet v$$, the projection of the gradient of $$T$$ to $$v$$.

After that, we use Maximize to find the direction v which attain the maximum decrease of temperature T,and it is just equal to the normalize of -Grad.

Clear[T,p, p0, v];
T[x_, y_, z_] = x^2 + y^2 + 4 z^2;
p = {x, y, z};
p0 = {x0, y0, z0};
v = {α, β, γ};
result1 =
Limit[(T[Sequence @@ (p0 + t*v)] - T[Sequence @@ p0])/t, t -> 0,
Direction -> "FromAbove"];

True
{-(2/Sqrt), 1/Sqrt, -(8/Sqrt)}