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.)

  • 2
    $\begingroup$ You could add an option:RegionFunction->(...) $\endgroup$
    – WateSoyan
    Commented Jun 1, 2015 at 15:25
  • $\begingroup$ Great! That was easy! Thanks $\endgroup$ Commented Jun 1, 2015 at 15:28
  • $\begingroup$ 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]] $\endgroup$ Commented Jun 1, 2015 at 15:31
  • $\begingroup$ And also -- read this (83692) $\endgroup$
    – Sektor
    Commented Jun 1, 2015 at 15:59
  • 2
    $\begingroup$ 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. $\endgroup$
    – N.J.Evans
    Commented Jun 1, 2015 at 16:09

1 Answer 1


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.


Which gives:

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.