Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'PLOT Direction Vectors of Partial Derivatives' topicStudent Support Forum > General > "PLOT Direction Vectors of Partial Derivatives"

Help | Reply To Topic
Author Comment/Response
jparra
10/06/11 06:29am

HI,

Im just plotted a function with is tangential plane and would like to add the vectors of the partial derivatives, in order to show the slop of the function in every point. I have read many forums, but sadly I don't get to the wished result.

If sb would help me, it would be great.

I paste you de code here:

nabla[f_, vars_] := Module[
{fullFunction},
fullFunction = f @@ vars;
Table[\!\(
\*SubscriptBox[\(\[PartialD]\), \(vars[\([\)\(i\)\(]\)]\)]\
fullFunction\), {i, 1, Length@vars}]
]
ebene[f_, x0_, y0_, x_, y_] :=
f[x0, y0] + (nabla[f[ x, y] &, {x, y}] /. {x -> x0, y -> y0}).({x,
y} - {x0, y0}) // Simplify
h[x_, y_] := x^2 + y^2
g[x_, y_] := x^2 - y^2
j[x_, y_] := -x^2 + y^2
l[x_, y_] := -x^2 - y^2

RuleTable = {h -> x^2 + y^2, g -> x^2 - y^2, j -> -x^2 + y^2,
l -> -x^2 - y^2};

xderivatives = {h -> {"\!\(\*SubscriptBox[\(h\), \(x\)]\)'(x,y)", "=",
2 x}, g -> {"\!\(\*SubscriptBox[\(g\), \(x\)]\)'(x,y)", "=",
2 x}, j -> {"\!\(\*SubscriptBox[\(j\), \(x\)]\)'(x,y)",
"=", -2 x},
l -> {"\!\(\*SubscriptBox[\(l\), \(x\)]\)'(x,y)", "=", -2 x}};

yderivatives = {h -> {"\!\(\*SubscriptBox[\(h\), \(y\)]\)'(x,y)", "=",
2 y}, g -> {"\!\(\*SubscriptBox[\(g\), \(y\)]\)'(x,y)",
"=", -2 y},
j -> {"\!\(\*SubscriptBox[\(j\), \(y\)]\)'(x,y)", "=", 2 y},
l -> {"\!\(\*SubscriptBox[\(l\), \(y\)]\)'(x,y)", "=", -2 y}};

Manipulate[
dd = ebene[func, x0, y0, x, y];
With[{x0 = x0, y0 = y0},
Column[{
Text@Grid[{
{Style[ToString[func] <> "(x,y)", Italic], "=",
TraditionalForm[(func /. RuleTable)]},
{Style[ToString[#[[1]], TraditionalForm], Italic], #[[2]],
TraditionalForm[#[[3]]]} &@(func /. xderivatives),
{Style[ToString[#[[1]], TraditionalForm], Italic], #[[2]],
TraditionalForm[#[[3]]]} &@(func /. yderivatives)
}, Alignment -> Left],
Show[{
Plot3D[{func[x, y], dd}, {x, -10, 10}, {y, -10, 10},
ClippingStyle -> None, AxesLabel -> {"x", "y", "z"},
PlotStyle -> {{Blue, Opacity[0.3]}, {Red, Opacity[0.3]}},
PlotRange -> {-200, 200}, Mesh -> None,
ImageSize -> {350, 350}, AspectRatio -> 1],
Graphics3D[{{Red, Sphere[{x0, y0, func[x0, y0]}, 0.5]}}]}]
}]
],
{{x0, 0, Subscript["x", 0]}, -10, 10},
{{y0, 0, Subscript["y", 0]}, -10, 10},
{{func, h, "function"}, {h, g, j, l}}, SaveDefinitions -> True,
TrackedSymbols :> Manipulate]

URL: ,
Help | Reply To Topic