# Plot a function on a restricted domain

I want to plot a function $f:\mathbb R^n \rightarrow \mathbb R$ restricted to a domain $D \subset \mathbb R^n$. The domain $D$ is usually specified as the set of zeros for a set of polynomial equations (i.e. an algebraic variety). For example consider the function $f(x,y) = x^{39}y^{63}$ on the ellipse $D := \left\{(x,y)\ \ \big|\ x^2+xy+y^2-1=0\right\}$. How would I plot this for example in Mathematica? (I am on version 7.0.)

• You could add an option:RegionFunction->(...) Jun 1 '15 at 15:25
• Great! That was easy! Thanks Jun 1 '15 at 15:28
• It doesn't seem to work: Plot3D[x^39*y^63, {x, 0, 1}, {y, 0, 1}, RegionFunction -> Function[{x, y}, x^2 + y^2 + x*y == 1]] Jun 1 '15 at 15:31
• And also -- read this (83692) Jun 1 '15 at 15:59
• That's because the 'region' you're plotting in is actually just an infinitesimally thin line. Try Plot3D[x^39*y^63, {x, 0, 1}, {y, 0, 1}, RegionFunction -> Function[{x, y}, x^2 + y^2 + x*y <=1&&x^2 + y^2 + x*y >0.9],PlotRange->All]. It isn't exactly what you want, but it'll show you what the problem is. I think you'd be better off with a different representation of your problem. ParametricPlot3D might work. Jun 1 '15 at 16:09

This is the closest way I can imagine to get what you were originally trying to get, though it still may not be the best way to plot what you care about.

First get a parametric representation of y in terms of x.

y[x_]=y/.Solve[x^2 + x*y + y^2 == 1, y,Reals];


Then make a parametric plot over the full range of x. I kept the two regions defined by the solution separate so you can see what's going on.

  ParametricPlot3D[{
{x,Max@y[x],x^39*(Max@y[x])^63},
{x,Min@y[x],x^39*(Min@y[x])^63}
}
,{x,-Sqrt[2],Sqrt[2]},PlotRange->All,BoxRatios->1]


Which gives:

• You probably want to use Set rather than SetDelayed to avoid evaluating Solve repeatedly. +1 nevertheless. Jun 1 '15 at 22:29
• Constructing a trigonometric parametrization of the ellipse ought to make for a neater plot. :) Jun 2 '15 at 12:44
• Or ParametricPlot3D[Evaluate[Thread[{x, y[x], x^39*y[x]^63}]], {x, -Sqrt[2], Sqrt[2]}, PlotRange -> All, BoxRatios -> 1] Nov 4 '15 at 19:06