Mathematical Principles for Scientific Computing and Visualization  
http://www.farinhansford.com/books/scv
by Gerald Farin and Dianne Hansford

This notebook demonstrates contouring. Two functions are given, f(x,y) and g(x,y). We then look at the zero contour of the difference of the two functions, f(x,y) - g(xy).

Figure 11.9 was created with this notebook.

See Chapter 11: Computing with Multivariate Functionsfor details.

Updated May 2008

(* Create the output folder *)
(SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];) 

(* Create the first function *)
(f1[x_,y_]:=2 Sin[x y];) 

(* Create the second function *)

(f2[x_,y_]:=0.7` (x^2)-0.4` (y^3)-0.4`;) 

(* Create the zero function *)
(f0[x_,y_]:=0;) 


(* Plot the first function *)
(* 90 plot points makes it a very smooth surface *)
(plot1=Plot3D[f1[x,y],{x,-2,2},{y,-2,2},Mesh->False,ViewPoint->{-0.5`,-1,0.8`},PlotPoints->90,ColorFunction->"RustTones", BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11}]) 


(* Plot second function *)
(plot2=Plot3D[f2[x,y],{x,-2,2},{y,-2,2},Mesh->False,ViewPoint->{0.5`,-1,0.8`},PlotPoints->90,ColorFunction->"ValentineTones", BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11}]) 


(* Put plots together *)
(Picture=Show[plot1,plot2,ViewPoint->{-0.5`,-1,0.8`},Axes->False]) 


(* Output to a postscript file *)
(* Uncomment when wanted *)
(* Export["function1.eps",plot1]; *) 
(* Export["function2.eps",plot2]; *) 
(* Export["two_functs.eps",Picture] *)

(* Now create the contour of the difference of the two functions *)
(* Plot f2 - f1 = 0 *)

pic=ContourPlot[f2[x,y]-f1[x,y],{x,-2,2},{y,-2,2},Contours->{0},BaseStyle->{"FontFamily"->"Helvetica","FontSize"->11}]

(* Output to a postscript file *)
(* Export["contour_intersect.eps",pic]; *)