# How to make a 3D plot over a triangular region

I'm new to mathematica. I'm trying to Plot3D the function f[x_,y_]:=x^3+2x y over the triangular region of the plane with vertices {-4,-1} and {0,3} and {4,-1}, then Plot the surface and its tangent plane at the point {1,2}

I tried everything, but I but I can't ever get the triangular region.

Thanks,

• You mean Plot3D[x^3+2 x y,{x,y}\[Element]Triangle[{{-4,-1},{0,3},{4,-1}}],ClippingStyle->None]?
– yode
Commented Jun 14, 2016 at 4:16
• If you get the answer.You can click the mark to choice you answer for your post like this .
– yode
Commented Jun 14, 2016 at 5:00

## 3 Answers

Try adding the following Option:

RegionFunction->Function[{x,y,z},y<3-x&&y>-1&&y<3+x]


Or, use this for x and y's region spexification:

{x,y}\[Element]Triangle[{{-4,-1},{4,-1},{0,3}}]


Of course, you'll have to change the functions accodingly in different situations.

There are a number of ways to plot. You can use regions in Plot3D. You can use RegionFunction as an option in Plot3D. You can implicitly define the region. In the following I show some ways (and one way to show tangent plane to point of interest).

Setup:

f[x_, y_] := x^3 + 2 x y;
tg = Triangle[{{-4, -1}, {0, 3}, {4, -1}}];
rmf = RegionMember[tg, {x, y}];
ir = ImplicitRegion[{rmf}~
Join~{z < f[x, y]}, {{x, -4, 4}, {y, -1, 3}, {z, -60, 60}}];
tg3 = Triangle[{##, -60} & @@@ tg[[1]]];
poi = {1, 2, f[1, 2]};
grd = Grad[f[x, y] - z, {x, y, z}] /. {x -> 1, y -> 2, z -> f[x, y]};


Visualization:

rp3 = RegionPlot3D[ir, PlotPoints -> 100, BoxRatios -> {1, 1, 1/2},
PlotRange -> All, Axes -> True, PlotStyle -> Opacity[0.3]];
p3 = Plot3D[x^3 + 2 x y, {x, y} \[Element] tg, Mesh -> None,
PlotStyle -> Blue, PlotRange -> {-60, 60}];
t3 = Graphics3D[{Red, tg3, Purple, PointSize[0.02], Point[poi]}];
plane = ContourPlot3D[
grd.({x, y, z} - poi) == 0, {x, -4, 4}, {y, -1, 3}, {z, -10, 10},
ContourStyle -> Opacity[0.6], Mesh -> None];
Show[rp3, p3, t3, plane]


As you first question I have give solution in the comment,I have repeat it here

Plot3D[x^3 + 2 x y, {x, y} \[Element]
Triangle[{{-4, -1}, {0, 3}, {4, -1}}], ClippingStyle -> None]


As your second question I call the Wolfram alpha to cope with it.

WolframAlpha["tangent plane to x^3 + 2 x y at (x, y) = (1, 2)",{{"Plot",1},"Content"}]


Actually I should leave your question alone and give it a tag of too board,but you are a first time to Mathematica SE.Anyway welcome to here. :)