Curve di Livello

Mostra il grafico tridimensionale di una funzione di due variabili e le relative curve di livello. 
  Diverse funzioni sono predefinite selezionabile mediante il menu a tendina. Volendo, se ne possono aggiungere atre.

dimimm = 300;
xmax=1;
funz = {x^2 - y^2, x/2 + y, x^2 + y^2, Sin[Pi x y]};
nomefunzione = {"f(x,y) = x^2 - y^2", "f(x,y) = x/2 + y", "f(x,y) = x^2 + y^2", "f(x,y) = sin(πxy)"};
Manipulate[
 Row[{
   Plot3D[f[x,y], {x, -xmax, xmax}, {y, -xmax, xmax}, PlotRange -> All,
    ClippingStyle -> None, Mesh -> 15, MeshStyle -> Black,
    Lighting -> "Neutral", ColorFunction -> "DarkRainbow", ImageSize -> dimimm],
   ContourPlot[f[x,y], {x, -xmax, xmax}, {y, -xmax, xmax}, PlotRange -> All, Contours -> 15, Axes -> False, PlotPoints -> 30, PlotRangePadding -> 0, Frame -> False, ColorFunction -> "DarkRainbow", ImageSize -> dimimm/1.5]
   }]
 , 
{{f,Function[{x1,y1},4-x1^2-y1^2],"f(x, y) ="},
{
Function[{x1,y1},4-x1^2-y1^2]->TraditionalForm[4-(x^2+y^2)],
Function[{x1,y1},Sin[π(x1-y1)]+Cos[π x1]]->TraditionalForm[Sin[π(x-y)]+Cos[π x]],
Function[{x1,y1},x1*Cos[π y1]]->TraditionalForm[x*Cos[π y]],
Function[{x1,y1},x1/2 + y1]->TraditionalForm[x/2 + y],
Function[{x1,y1},Sin[2 Pi x1 y1]]->TraditionalForm[Sin[ 2π x y]],
Function[{x1,y1},(x1^2-y1^2)/2]->TraditionalForm[(x^2-y^2)/2]
},
PopupMenu}, ControlPlacement -> Left]

Derivate Parziali

Mostra il grafico tridimensionale di una funzione di due variabili (x e y)
e la rappresentazione grafica delle derivate parziali in un generico punto (x0, y0).
Sono predefinite quattro funzioni, selezionabili mediante il menu a tendina. Volendo, se ne possono aggiungere atre.

Manipulate[

{{xmin,xmax},{ymin,ymax}}={{-3,3},{-3,3}};
{zmin,zmax}=Evaluate@Switch[f,
Function[{x1,y1},Sin[x1-y1]+Cos[x1]],{-2,2},
Function[{x1,y1},x1*Cos[y1]],{-3,3},
Function[{x1,y1},(x1^2-y1^2)/2],{-5,5},
Function[{x1,y1},4-x1^2-y1^2],{-14,4},
Function[{x1,y1},x1*Cos[π y1]],{-1,1},
Function[{x1,y1},x1/2 + y1],{-1,1},
Function[{x1,y1},Sin[x1 y1]],{-1,1}
];
plotrange={{xmin,xmax},{ymin,ymax},{zmin,zmax}};


Column[{Item[
Grid[{
{Text@Style[Row[{Style["f",Italic],"(",Style["x",Italic],", ",Style["y",Italic],") = ",TraditionalForm[f[x,y]]}],16],SpanFromLeft},
{
Show[
Plot3D[f[x,y],{x,xmin,xmax},{y,ymin,ymax},Mesh -> 15, MeshStyle -> Black,PlotStyle->{Gray,Opacity[surfopac]},BoundaryStyle->None],

If[fixy,ParametricPlot3D[{x,y0,f[x,y0]},{x,xmin,xmax},PlotStyle->{Thick,Darker[Green,0.5]}],{}],

If[fixx,ParametricPlot3D[{x0,y,f[x0,y]},{y,ymin,ymax},PlotStyle->{Thick,Purple}],{}],

If[showxpart,ParametricPlot3D[{1t+x0,0t+y0,(D[f[x,y],x]/.{x->x0,y->y0})t+f[x0,y0]},{t,-1,1},PlotStyle->{Green,Thick}],{}],

If[showypart,ParametricPlot3D[{0t+x0,1t+y0,(D[f[x,y],y]/.{x->x0,y->y0})t+f[x0,y0]},{t,-1,1},PlotStyle->{Red,Thick}],{}],

Graphics3D[{
{Black,PointSize[0.03],Point[{{x0,y0,f[x0,y0]}}]},
If[fixx,{Lighter[Purple,0.5],Opacity[0.5],Cuboid[{x0,ymin*1.1,zmin*1.1},{x0,ymax*1.1,zmax*1.1}]},{}],
If[fixy,{Green,Opacity[0.3],Cuboid[{xmin*1.1,y0,zmin*1.1},{xmax*1.1,y0,zmax*1.1}]},{}]
}],

Boxed->True,Axes->True,AxesEdge->Table[-1,{3},{2}],ImageSize->{400,400},
AxesLabel->Map[Style[#,14]&,{"x","y","z"}],PlotRange->plotrange
]
}},Alignment->Top],
ItemSize->{Automatic,32},Alignment->Top
]}],

{{f,Function[{x1,y1},4-x1^2-y1^2],"f(x, y) ="},
{
Function[{x1,y1},4-x1^2-y1^2]->TraditionalForm[4-(x^2+y^2)],
Function[{x1,y1},Sin[x1-y1]+Cos[x1]]->TraditionalForm[Sin[x-y]+Cos[x]],
Function[{x1,y1},x1*Cos[y1]]->TraditionalForm[x*Cos[y]],
Function[{x1,y1},(x1^2-y1^2)/2]->TraditionalForm[(x^2-y^2)/2],
Function[{x1,y1},x1/2 + y1]->TraditionalForm[x/2 + y],
Function[{x1,y1},Sin[x1 y1]]->TraditionalForm[Sin[x y/2]]
},
PopupMenu}
,
{{x0,0,Subscript["x",0]},-3,3},
{{y0,0,Subscript["y",0]},-3,3},
{{fixy,False,"y fissata"},{True,False},ControlPlacement->Left},
{{showxpart,False,"mostra d/dx"},{True,False},ControlPlacement->Left},
Delimiter,
{{fixx,False,"x fissata"},{True,False},ControlPlacement->Left},
{{showypart,False,"mostra d/dy"},{True,False},ControlPlacement->Left},
Delimiter,
{{surfopac,0.5,"opacità della superficie"},0,1,ControlPlacement->Top},
TrackedSymbols->Manipulate,AutorunSequencing->{1,2,3,4,6,10}
]

Vettore Gradiente

Mostra il grafico tridimensionale di una funzione di due variabili (x e y) 
e il vettore gradiente sul piano (x, y) in un punto del piano, selezionabile mediante un cursore.
  Sono predefinite quattro funzioni, selezionabili mediante il menu a tendina. Volendo, se ne possono aggiungere atre.

Manipulate[
{{xmin,xmax},{ymin,ymax}}={{-2,2},{-2,2}};
isize= Medium;
zmin = NMinimize[{f[x,y],{xmin≤ x ≤ xmax, ymin≤y≤ymax}},{x,y}][[1]];
zmax = NMaximize[{f[x,y],{xmin≤ x ≤ xmax, ymin≤y≤ymax}},{x,y}][[1]];
zlevel = -2(* zmin - 1.5 (zmax-zmin)*);
Show[
Plot3D[f[x,y],{x,xmin,xmax}, {y,ymin,ymax},ImageSize->isize,PlotStyle->Opacity[.5], PlotRange->{xmin,xmax}
],
Graphics3D[{Red,Arrowheads[Large], PointSize[Large],Thickness[Large]}]
,
Graphics3D[{
Texture[ContourPlot[f[x,y],{x,xmin,xmax}, {y,ymin,ymax},Axes->False,PlotRangePadding->0,Frame->False,ColorFunction -> "DarkRainbow",
Epilog->{Red,Arrowheads[Large],PointSize[Large],Thickness[Large],Point[{point[[1]],point[[2]]}]
,Arrow[{{point[[1]],point[[2]]},
{point[[1]] + D[f[x,y],x]/. {x->point[[1]],y->point[[2]]},
point[[2]]+  D[f[x,y],y]/.{x->point[[1]],y->point[[2]]}}
}]
}
]]
,EdgeForm[],Polygon[{{xmin,ymin,zlevel},{xmax,ymin,zlevel},{xmax,ymax,zlevel},{xmin,ymax,zlevel}},
VertexTextureCoordinates->{{0,0},{1,0},{1,1},{0,1}}]},
Lighting->"Neutral"
]
,PlotRange->All, BoxRatios->{1,1,1},FaceGrids->{Back,Left}
]
,
Row[{Style["f",Italic],"(",Style["x",Italic],",", Style["y",Italic],") ="}],
{{f,Function[{x1,y1},2-(x1/2)^2-(y1/2)^2],""},{
Function[{x1,y1},2-(x1/2)^2-(y1/2)^2]->TraditionalForm[2-(x/2)^2-(y/2)^2]
,Function[{x1,y1},1.5 Sin[x1 y1]]->TraditionalForm[Sin[x y]]
,Function[{x1,y1},x1*Cos[y1]]->TraditionalForm[x*Cos[y]]
,Function[{x1,y1},(x1^2-y1^2)/2]->TraditionalForm[(x^2-y^2)/2]
},
PopupMenu},
Delimiter,
Row[{"(",Subscript[Style["x",Italic],0],", ", Subscript[Style["y",Italic],0],") = "}],
{{point,{Mean[{.5 xmin,xmax}],Mean[{.6ymin,ymax}]},""},
 {xmin,ymin},{xmax,ymax}, ControlType->Slider2D},
TrackedSymbols:> {f, point},
AutorunSequencing->{1,2},
ControlPlacement-> Left
]

Piano Tangente

Mostra il grafico tridimensionale di una funzione di due variabili (x e y) 
e il piano tangente alla superficie in un generico punto, selezionabile mediante cursore.
E' rappresentata solo una porzione circolare del piano tangente, 
avente raggio proporzionale al modulo del gradiente della funzione in quel punto.
Sono predefinite cinque funzioni, selezionabili mediante il menu a tendina. Volendo, se ne possono aggiungere atre.

Manipulate[
Module[{f,dx,dy,grad},
Switch[fcn,
f1,
f[x_,y_]:=2-x^2-y^2;
xmin=-.8; xmax=.8; ymin=-.8; ymax=.8;zmin=0;zmax=2;
{xgrid1,ygrid1}={1/2,1/2},
f2,
f[x_,y_]:=(x^2-y^2)/2;
xmin=-2.5; xmax=2.5; ymin=-2.5; ymax=2.5;zmin=-2.1;zmax=2.1;
{xgrid1,ygrid1}={1/2,1/2},
f3,
f[x_,y_]:=x Cos[2y];
xmin=-3; xmax=3; ymin=-Pi; ymax=Pi;zmin=-3.1;zmax=3.1;
{xgrid1,ygrid1}={1,Pi/12},
f4,
f[x_,y_]:=Sin[x]Cos[y];
xmin=-1.5Pi; xmax=1.5Pi; ymin=-1.5Pi; ymax=1.5Pi;zmin=-1.1;zmax=1.1;
{xgrid1,ygrid1}={Pi/12,Pi/12},
f5,
f[x_,y_]:=(x+y)/2;
xmin=-3; xmax=3; ymin=-3; ymax=3;zmin=-2.1;zmax=2.1;
{xgrid1,ygrid1}={1/2,1/2}
];
dx[x_,y_] = D[f[x,y],x];
dy[x_,y_] = D[f[x,y],y];
grad[x_,y_] = {dx[x,y],dy[x,y],-1};
p3 = Plot3D[f[x,y],{x,-2,2},{y,-2,2},PlotStyle -> Opacity[.5]];
{a,b} = pt;
Show[
p3,
Graphics3D[{Red,Point[{a,b,f[a,b]}],ColorData[1][2],Opacity[.5],Cylinder[{{a,b,f[a,b]},{a,b,f[a,b]}+ .01grad[a,b]},(Sqrt[((dx[a,b])^2) + ((dy[a,b])^2)])]}],
PlotRange -> {zmin-1,zmax+1},BoxRatios->Automatic,ImageSize->{400,400}]],
{{pt,{0,0}, "(a,b)"},{xmin,ymin},{xmax,ymax}},
{{fcn,f1,"f(x,y) = "},{f1->TraditionalForm[4 - (x^2) - (y^2)],f2->TraditionalForm[((x^2) - (y^2))/2],f5->TraditionalForm[(x + y)/2],f3->TraditionalForm[x Cos[2 y]],f4->TraditionalForm[Sin[x]Cos[y]]},ControlType->PopupMenu},TrackedSymbols->Manipulate,ControlPlacement->Left
]