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.)
1 Answer
$\begingroup$
$\endgroup$
3
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:
-
2$\begingroup$ You probably want to use
Set
rather thanSetDelayed
to avoid evaluatingSolve
repeatedly. +1 nevertheless. $\endgroup$ Jun 1, 2015 at 22:29 -
1$\begingroup$ Constructing a trigonometric parametrization of the ellipse ought to make for a neater plot. :) $\endgroup$ 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$ Nov 4, 2015 at 19:06
(83692)
$\endgroup$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$