Unit Normal for CurvesLet's take y=x^2. This can be written as f(x,y)=0 if f(x,y)=x^2-y.
In[92]:=
Clear[f,x,y]
f[x_,y_]:=x^2-y
In[93]:=
grad2[f][x,y]
Out[93]=
{2 x, -1}
In[94]:=
u=grad2[f][x,y]/norm2[grad2[f,x,y]]
Out[94]=
2 x 1
{-------------, -(-------------)}
2 2 2 2
Sqrt[f + x ] Sqrt[f + x ]
Let's test at a point.
In[95]:=
u/.x->0
Out[95]=
1
{0, -(--------)}
2
Sqrt[f ]
This vector is pointing outward. Let's see if you are not sure.
Remember, to draw a vector at (x0,y0) in the direction of v=(v1,v2), you plot
(x0+tv1,y0+tv2), t from 0 to 1.
In[96]:=
vector=ParametricPlot[{0,-t}, {t,0,1},
PlotStyle->{RGBColor[1,0,0]},DisplayFunction->Identity];
In[97]:=
curve=Plot[x^2,{x,-2,2},DisplayFunction->Identity];
In[98]:=
Show[curve,vector,DisplayFunction->$DisplayFunction]

Out[99]=
-Graphics-
How about x^2+2y^2+x-y=6?
In[100]:=
Clear[f,x,y,u]
f[x_,y_]:=x^2+2 y^2+x-y-6
In[101]:=
grad2[f][x,y]
Out[101]=
{1 + 2 x, -1 + 4 y}
In[102]:=
u=grad2[f][x,y]/norm2[grad2[f][x,y]]
Out[102]=
1 + 2 x
{------------------------------,
2 2
Sqrt[(1 + 2 x) + (-1 + 4 y) ]
-1 + 4 y
------------------------------}
2 2
Sqrt[(1 + 2 x) + (-1 + 4 y) ]
In[103]:=
utest=u/.{x->2,y->0}
Out[103]=
5 1
{--------, -(--------)}
Sqrt[26] Sqrt[26]
In[104]:=
<<Graphics`ImplicitPlot`
In[105]:=
curve=ImplicitPlot[f[x,y]==0,{x,-3,3},{y,-3,3},
DisplayFunction->Identity]
Out[105]=
-ContourGraphics-
In[106]:=
vector=ParametricPlot[{2+t*utest[[1]],0+t*utest[[2]]},
{t,0,1},PlotStyle->{RGBColor[1,0,0]},
DisplayFunction->Identity];
In[107]:=
Show[curve,vector,DisplayFunction->$DisplayFunction]

Out[108]=
-Graphics-