2
$\begingroup$

I wanted to plot a function of two variables so I have decided to make use of Mathematica.

The function is

$z =\ ( 1 / 6) \ y^2 + \ ( \pi \ / 6 )(x^2y) $

where

$\ y=\sqrt{9-x^2} $

Sorry for what may be a simple question, but how do I plot the graph with the restriction on y?

I have written this code

 Plot3D[1/6  * (y)^2 + Pi/6* x^2 * (y), {x, -3, 3}, {y, Sqrt[9 - x^2], 
  Sqrt[9 - x^2]}]

But I get a wireframe type of graph back.

How can I get a filled in graph which depicts the function along with its restriction? Thank you.

$\endgroup$
6
  • $\begingroup$ Consider Plot3D[1/6*(y)^2 + Pi/6*x^2*(y), {x, -3, 3}, {y, Sqrt[9 - x^2], Sqrt[9 - x^2]}, ViewPoint -> Front] and Plot[1/6*(y)^2 + Pi/6*x^2*(y) /. y -> Sqrt[9 - x^2], {x, -3, 3}]. The second makes the substitution prior to plotting. $\endgroup$
    – Edmund
    Commented Mar 12, 2017 at 19:11
  • $\begingroup$ I could be misinterpreting your suggestion, but running these two lines gives me a 2D function along with a graph plot quite like what I already had. $\endgroup$
    – Larry
    Commented Mar 12, 2017 at 19:53
  • 1
    $\begingroup$ It is not quite clear to me what sort of graph you are looking for. Maybe this one: With[{y=Sqrt[9-x^2]},ParametricPlot3D[{x, y, y^2/6 +x^2 y \[Pi]/6}, {x, -3, 3}]]? $\endgroup$ Commented Mar 12, 2017 at 20:05
  • $\begingroup$ Fred I think that is what I'm looking for. Thank you very much. Is there a way to project the lines down to z = 0, so as to make it a surface rather than a function? $\endgroup$
    – Larry
    Commented Mar 12, 2017 at 20:27
  • 1
    $\begingroup$ You can modify Fred's code like this With[{y = Sqrt[9 - x^2]}, ParametricPlot3D[{x, y, u (y^2/6 + x^2 y Pi/6)}, {x, -3, 3}, {u, 0, 1}]] $\endgroup$ Commented Mar 12, 2017 at 20:44

1 Answer 1

2
$\begingroup$
r[t_] := {3 Cos[t], 3 Sin[t], 9 Sin[t]^2/6 + 27 Pi Cos[t]^2 Sin[t]/6} 
pp = ParametricPlot3D[r[t], {t, 0, 2 Pi}, PlotStyle -> Red];
p3 = Plot3D[y^2/6 + Pi x^2 y/6, {x, -3, 3}, {y, -3, 3}, Mesh -> None, 
   PlotStyle -> Opacity[0.4]];
Show[p3, pp, BoxRatios -> Automatic]

enter image description here

$\endgroup$

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.