Plot the cusp catastrophe surface

You can actually do this via pgfplots but to make it a little nicer you have to switch to LuaLaTeX since PDFLaTeX chokes up on memory limitations (due to many samples per axis. You don't need that much but why not :P).

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[y domain=-4:4,
          domain=-2:2,
          restrict z to domain=-5:5,
          samples=100,
          view={43}{8},
          mesh/interior colormap name=hot,
          colormap/blackwhite,
          xlabel=$x$,ylabel=$u$,zlabel=$v$,grid=both
         ]
\addplot3[surf] {-4*x^3 - 2*y*x};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

If you decide the hide the rough edges you can get a lo-fi version which LaTeX can also handle

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\begin{document}
\begin{tikzpicture}
\begin{axis}[y domain=-3:3,
          domain=-2:2,zmin=-3,zmax=3,
          restrict z to domain=-5:5,
          samples=45,
          view={48}{15},
          mesh/interior colormap name=hot,
          colormap/blackwhite,
          xlabel=$x$,ylabel=$u$,zlabel=$v$,grid=both
         ]
\addplot3[surf] {-4*x^3 - 2*y*x};
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here


I think what you are asking for it is precisely in ePiX's, (http://bay.uchicago.edu/tex-archive/graphics/epix/samples/butterfly.xp) examples.

If I understand the code, the strategy is to draw the surface in three patches. It would be fun to translate this into pgfplots and asymptote. Maybe asymptote can even define this curve implicitly (it is very good at that).

Here it is an image of the result (I didn't make it):

butterfly


Asymptote can plot an implicitly defined surface using the smoothcontour3 module. This module has been incorporated into the (just-released) version 2.33 of Asymptote, but if you don't have an earlier version, you can install the module using the link above. (Just copy the file into the directory containing your image.) Here's how the surface you describe might be drawn:

\documentclass{standalone}
\usepackage{asypictureB}
\begin{document}
\begin{asypicture}{name=catastrophe_surface}
settings.outformat = "png";
settings.render = 32;
size(8cm);
import smoothcontour3;
import graph3;

currentprojection=perspective(3*(4,-6,3));

real f(real v, real u, real x) { return 4x^3 + 2u*x + v; }
draw(implicitsurface(f,(-2,-2,-2),(2,2,2), n=15, overlapedges=true), 
    surfacepen=material(diffusepen=gray, 
    ambientpen=blue));

zaxis3("$x$", Bounds, InTicks, zmin=-2, zmax=2);
xaxis3("$v$", Bounds, InTicks);
yaxis3("$u$", Bounds, InTicks(beginlabel=false));
\end{asypicture}
\end{document}

enter image description here

It can even produce a vector graphics version if you change the first two lines inside the asypicture environment to

settings.outformat = "pdf";
settings.render = 0;

but the resulting pdf file will be enormous and will look bad in most viewers (in my experience, it looks okay in Adobe Reader, but not in any other I've tried).

Either way, for this particular problem, I think you're better off using the small bit of math

4x^3 + 2ux + v = 0
v = -4x^3 - 2ux

to turn this into the plot of a function rather than an implicitly defined surface. Implicitly defined surfaces generally don't look as nice.

Here's a non-implicit version with Asymptote. (Note that it requires my crop3D module.)

settings.outformat = "png";
settings.render = 16;
size(8cm);

import graph3;
import crop3D;
currentprojection=perspective(3*(4,-6,3));

triple F(pair ux) {
  real u = ux.x;
  real x = ux.y;
  return (-4x^3 - 2*u*x, u, x);
}
surface s = surface(F, (-2,-2), (2,2), nu=20, usplinetype=Spline);
draw(crop(s,(-2,-2,-2),(2,2,2)), surfacepen=material(diffusepen=gray, ambientpen=blue));

zaxis3("$x$", Bounds, InTicks, zmin=-2, zmax=2);
xaxis3("$v$", Bounds, InTicks);
yaxis3("$u$", Bounds, InTicks(beginlabel=false));

It compiles more quickly than the implicit version and gives, in my opinion, a nicer result:

enter image description here