(*This Mathematica code was written by John Zweck (zweck@utdallas.edu) and generates a mathematical curve/surface that can be printed using a 3D printer. This model can (probably) be printed by Shapeways.*)

(*If you evaluate this Mathematica notebook,the curve/surface will be rendered using computer graphics.*)

(*If you uncomment the export line at the end of the code and set the directory path appropriately for your system you will obtain an STL file that can be sent to a 3D printer.*)

(*The STL file can also be viewed using the open source software Meshlab.*)

(*You may modify this code in any way you like.*)


(* This surface is the graph of a function z=f(x,y) that has one local maximum but no global maximum or minimum. The triangles in the mesh for this surface are first formed in the xy-plane and then lifted up to form a discretization of the surface using the function f. Since f has lare derivatives the resulting mesh on the surface is far from optimal. The thick base was made to hide discretization errors due to the suboptimal mesh. There must be a better way to implement such surfaces but I haven't had time to work it out yet *)

xyscale=12;
zscale=0.3*xyscale;

MinZ=-10*zscale;

RegionZ1=ImplicitRegion[zscale*(3*X*Y-X^3 - Y^2)> MinZ,{X,Y}];

RegionZ2 = ImplicitRegion[Y>0,{X,Y}];

RegionZ=RegionIntersection[RegionZ1,RegionZ2];

RegionXY = Rectangle[{-2,Exp[-4]},{3.2,Exp[2]}];

RegionBase = Rectangle[{-2,-4},{3.3,2.1}];

Region=RegionIntersection[RegionZ,RegionXY];

RegionPlot[RegionZ]

LocalMaxNotGlobal=ParametricPlot3D[{xyscale*u,xyscale*Log[v],zscale*(3*u*v-u^3 - v^2)},{u,v} ∈ Region,
Mesh->False, MaxRecursion->15,  PlotStyle->{Thickness[2]}];

Base =ParametricPlot3D[{xyscale*u,xyscale*v,MinZ},
{u,v} ∈ RegionBase,
Mesh->False, MaxRecursion->4,  PlotStyle->{Thickness[3]}];

output= Show[LocalMaxNotGlobal, Base]

(*Export["LocalMaxNotGlobal.stl",output];*)