1
$\begingroup$

I'm writing an exam for my calculus students and am seeking help with using Mathematica on a particular problem.

Here's my idea: I want to give a multiple choice problem that has four choices of level curves for a surface (either $z=\sin(x)\sin(y)$ or $z=x^2-y^2$) and what's supposed to be the corresponding gradient vector field.

Here's my problem: I am able to plot two possibilities (the actual gradient vector field and the negative of that). I'd like to provide two other options, each with the vectors being tangential to the level curves (rather than orthogonal, as with the gradient vector field). Is there a way to rotate the vectors in a vector field by $90^{\circ}$? Is this a mathematical question that I should direct to math.SE?

Thanks in advance for your help!

$\endgroup$
  • $\begingroup$ Can you be more specific? For example, if you plot the field with VectorPlot[{y, x}, {x, -3, 3}, {y, -3, 3}], then you can get orthogonals just by swapping the arguments VectorPlot[{y, x}, {x, -3, 3}, {y, -3, 3}] or using minus signs. $\endgroup$ – bill s Dec 1 '14 at 19:01
  • $\begingroup$ If $f(x,y)=\sin(x)\sin(y)$, the actual gradient vector field is given by VectorPlot[{Cos[x]Sin[y],Sin[x]Cos[y]},{x,-3,3},{y,-3,3}] and these vectors are orthogonal to the level curves of $f$. I'm looking to plot a vector field with vectors that are all tangential to the level curves of $f$. $\endgroup$ – Peter Dec 1 '14 at 19:08
1
$\begingroup$
 grad = Grad[x^2 - y^2, {x, y}];
VectorPlot[{grad[[2]], -grad[[1]]}, {x, -2, 2}, {y, -2, 2}]

enter image description here

grad2 = Grad[Sin[x] Sin[y], {x, y}];
VectorPlot[{grad2[[2]], -grad2[[1]]}, {x, -2, 2}, {y, -2, 2}]

enter image description here

$\endgroup$
  • $\begingroup$ Do you mind explaining what the {grad[[2]], -grad[[1]]} part of your code does? $\endgroup$ – Peter Dec 1 '14 at 19:12
  • $\begingroup$ This the reciprocal of the gradient filed. if you want to find the slop of line orthogonal to another line then the slop2 is equal to -1/slop1. in another word, {grad[[1]], grad[[2]]}.{grad[[2]], -grad[[1]]}=0 $\endgroup$ – Algohi Dec 1 '14 at 19:18
  • $\begingroup$ Oh, okay. Thank you! $\endgroup$ – Peter Dec 1 '14 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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