(*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 project was supported by the National Science Foundation through a Supplement to the UTeach Dallas Robert Noyce Scholarship Program (DUE 1544159).*)

(* This model is the graph of a surface with two local maxima and no other critical points. One problem is that it's not easy to see from the model that there really are no other critical points. A nice project would be to work out how to improve the design of this surface to make the central trough slope more steeply without introducing additional critical points.*)

xyscale=3;
zscale=10;

MinZ= -4*zscale;

c=10;

zscale=zscale/(c^4);

RegionZ=ImplicitRegion[zscale*(-(x^2-c^2)^2 - (x^2*y-c*x)^2) > MinZ,{x,y}];
RegionXY = Rectangle[{-20,-15},{20,15}];
RegionBase1 = Rectangle[{-18,-15},{18,15}];
RegionBase2 = RegionUnion[Rectangle[{-2.5,-14},{2.5,14}], Rectangle[{-18,4},{-7,15}],Rectangle[{-18,-15},{-7,-6.5}],Rectangle[{7.5,5.5},{18,15}],Rectangle[{7,-15},{18,-4}]];

RegionBase = RegionDifference[RegionBase1,RegionBase2];

Region=RegionIntersection[RegionXY,RegionZ];

RegionPlot[Region]

RegionPlot[RegionBase]

TwoLocalMax=ParametricPlot3D[{xyscale*u,xyscale*v,zscale*(-(u^2-c^2)^2 - (u^2*v-c*u)^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[5]}];

output= Show[TwoLocalMax,Base]

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