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


This notebook demonstrates quadratic forms and contour plots.
Three quadratic forms are created: an elliptic paraboloid, a hyperbolic paraboloid, and a cylindrical paraboloid.

Figure 11.7 was created with this notebook.

See Chapter 11: Computing with multivariate functions for details.

Updated May 2008

(* Set output folder to folder this file is in *)

SetDirectory[ToFileName[Extract["FileName"/.NotebookInformation[EvaluationNotebook[]],{1},FrontEnd`FileName]]];

(* Create xxxx *)

data=Transpose[{{1.`,1},{2,2},{0,0},{-1,-1},{-2,-2}}]

A1=data.Transpose[data]

Eigenvalues[A1]

{e1,e2}=Eigenvectors[A1];

Print["e1 = ",e1," e2=",e2]

(* Form an elliptic paraboloid *)
f1[x_,y_]:={x,y}.A1.{x,y};

(* Form a hyperbolic paraboloid *)
A2={{1.`,-2},{-2,1}};
f2[x_,y_]:={x,y}.A2.{x,y};

(* Form a cylindrical paraboloid *)
A3={{2.`,0},{0,0}};
f3[x_,y_]:={x,y}.A3.{x,y};

(* Create function plots *)
(* Create a color version to view and a gray scale version for the postscript file *)

p1=Plot3D[f1[x,y],{x,-1,1},{y,-1,1},Mesh->False,Axes->False,Boxed->False,ViewPoint->{0,-3,0.5`}, PlotPoints->90]

p1gray=Plot3D[f1[x,y],{x,-1,1},{y,-1,1},Mesh->False,Axes->False,Boxed->False,ViewPoint->{0,-3,0.5`},ColorFunction->ColorData["GrayTones"], PlotPoints->90,ColorOutput->CMYKColor];



p2=Plot3D[f2[x,y],{x,-1,1},{y,-1,1},Mesh->False,Axes->False,Boxed->False,ViewPoint->{0,-3,0.5`},PlotPoints->90]

p2gray=Plot3D[f2[x,y],{x,-1,1},{y,-1,1},Mesh->False,Axes->False,Boxed->False,ViewPoint->{0,-3,0.5`},ColorFunction->ColorData["GrayTones"], PlotPoints->90,ColorOutput->CMYKColor];



p3=Plot3D[f3[x,y],{x,-1,1},{y,-1,1},Mesh->False,Axes->False,Boxed->False,ViewPoint->{0,-3,0.5`}, PlotPoints->90]

p3gray=Plot3D[f3[x,y],{x,-1,1},{y,-1,1},Mesh->False,Axes->False,Boxed->False,ViewPoint->{0,-3,0.5`},ColorFunction->ColorData["GrayTones"], PlotPoints->90,ColorOutput->CMYKColor];


(* Create contour plots of each *)
(* Create a color version to view and a grayscale version for the ps output *)

c1=ContourPlot[f1[x,y],{x,-1,1},{y,-1,1},FrameTicks->None]

c1gray=ContourPlot[f1[x,y],{x,-1,1},{y,-1,1},FrameTicks->None,ColorFunction->ColorData["GrayTones"], ColorOutput->CMYKColor];

c2=ContourPlot[f2[x,y],{x,-1,1},{y,-1,1},FrameTicks->None]

c2gray=ContourPlot[f2[x,y],{x,-1,1},{y,-1,1},FrameTicks->None,ColorFunction->ColorData["GrayTones"], ColorOutput->CMYKColor];

c3=ContourPlot[f3[x,y],{x,-1,1},{y,-1,1},FrameTicks->None]

c3gray=ContourPlot[f3[x,y],{x,-1,1},{y,-1,1},FrameTicks->None,ColorFunction->ColorData["GrayTones"], ColorOutput->CMYKColor];

(* Arrange the gray scale images in a grid for the ps output *)
barray=GraphicsGrid[{{p1gray,p2gray,p3gray},{c1gray,c2gray,c3gray}}];

(* Show[barray] *)

(* Output to file *)
(* Export["threecontours.eps",barray]; *)

-