Is there a systematic way to construct functions with prescribed local extrema? I'm teaching multivariable calculus and having a hard time coming up with optimization problems. 
Suppose I have three lists of points $\{a_1, \dotsc, a_r\}$, $\{b_1, \dotsc, b_s\}$, and $\{c_1, \dotsc, c_t\}$ in $\Bbb R^n$. Is it possible to construct a function $f:\Bbb R^n\to\Bbb R$ that has a local max at every $a_i$, a local min at every $b_i$, a saddle point at every $c_i$, and no other local extrema? Furthermore, is it possible to accomplish this with $f\in\Bbb R[x_1, \dotsc, x_n]$?
A weaker version of this question is: given points $\{p_1,\dotsc,p_k\}$ in $\Bbb R^n$, is it possible to construct a function $f:\Bbb R^n\to \Bbb R$ whose set of critical points is exactly $\{p_1,\dotsc,p_k\}$?
So, for instance, is there a systematic way to construct $f\in\Bbb R[x, y, z]$ with a local maximum at $(1, -3, 2)$ and a saddle point at $(2, -8, 1)$?
 A: In the simpler case of $f:\mathbb{R}^2\to\mathbb{R}$

(i) minima if both $f_{xx}$ and $f_{yy}$ are positive and $f^2_{xy}< fxxfyy$,
  (ii) maxima if both $f_{xx}$ and $f_{yy}$ are negative and $f^2_{xy} <f_{xx}f_{yy}$,
  (iii)saddle points if $f_{xx}$ and $f_{yy}$ have opposite signs or $f^2_{xy} >f_{xx}f_{yy}$.

Take local maximum at $(1,-3)$ and saddle point at $(2,-8)$ from example, the $f$ satisfying the following sufficient but not necessary condition will meet our requirement:
$f_x(1)=f_x(2)=f_y(-3)=f_y(-8)=0$
$f_{xx}(1)<0, f_{yy}(-3)<0, f_{xx}(2)>0 , f_{yy}(-8)<0, f_{xy}=f_{yx}=0$
apparently
$f_x=k(x-1)(x-2), f_y=-m(y+8)(y+5)(y+3)$ satisfies all above condition with $k, m>0$ (draw a graph of $f_x, f_y$ will help in drawing the conclusion).
Solve the PDE and choose $k,m$, integration constants freely will arrive at a function to our satisfaction. The case with $f:\mathbb{R}^3\to\mathbb{R}$ can be generated similarly. Only problem the function thus created may be too simple to your like as $x,y,z$ are always decoupled. May be you can start with some 2 variable function with desired complexity and extrema and saddle points, then add 3rd,4th ... decoupled dimension...
