Mathematica 3D Graphing (3D Plot) Issue

AI Thread Summary
The user is experiencing issues graphing the equations "3x - y = 4" and "x + y + z = 5" in Mathematica, with the latter not displaying despite being in the correct range. It was clarified that Plot3D only accepts functions of two variables, requiring the user to solve for z or use ContourPlot3D for three-variable equations. The user successfully graphed "x + y + z = 5" using ContourPlot3D but is struggling to plot both equations together. A solution was suggested to plot the equations by rearranging them to express y in terms of x and z, allowing them to be displayed on the same axes. The discussion highlights the need for understanding the specific requirements of Mathematica's plotting functions.
Ascendant0
Messages
175
Reaction score
38
I'm trying to graph two equations to compare the two visually. For some reason, one of them isn't showing up, even though I'm in a range to where it should be. See the screenshot below.

The "3x - y = 4" is graphing fine, but for some reason, "x + y + z = 5" isn't showing up. At first, I tried them together. When that didn't work, I tried to graph the "x + y + z = 5" by itself, and it still didn't show up. To make sure something wasn't wrong with Mathematica, I figured I'd try graphing the "3x - y = 4" again, this time by itself. Again, it graphed that one fine, just like in the first graph. Can someone tell me what's going on here, and how to get it to graph the equation?

Also, for some reason when I use "Plot3D," it only lets me give a range for the x and y coordinates. If I try to add in a range for z as well, it gives me an error. Not sure why, as I feel it would make sense for us to give a range in all three, but is there a special way you have to add in the z range that's different than how you enter in the x and y range?

Graphs.JPG
 
Physics news on Phys.org
Ascendant0 said:
I tried to graph the "x + y + z = 5" by itself, and it still didn't show up.
Plot3D is looking for a function of 2 variables. You cannot have 3 variables in the expression.

You could solve for z explicitly or you can plot that expression using ContourPlot3D.
 
  • Like
Likes Ascendant0 and PhDeezNutz
Dale said:
Plot3D is looking for a function of 2 variables. You cannot have 3 variables in the expression.

You could solve for z explicitly or you can plot that expression using ContourPlot3D.
Thank you. I'm new to Mathematica, so I'm still learning all the various commands.

So, I used ContourPlot3D and that worked for the function that wasn't showing up before. But, how can I graph both of them on the same plot? I tried grouping them similar to what I do with Plot3D, but it seems to only take one function when I set it up like I did above with Plot3D (for the 2 equations together in one command).
 
Plot3D plots the surface defined by z = f(x,y).

In your case, 3x - y = 4 is really 3x - y + 0z = 4. You can't solve that for z, but you can solve it for y and plot y = f(z,x) \equiv 3x - 4. You can then plot y = g(z,x) \equiv 5 - x - z on the same axes. That leaves you with z and x as the horizontal axes, but you can change that by setting ViewVertical to {1,0,0} to make the z axis vertical (see list of options here and detailed example here). (Listing the arguments as z followed by x ensures that you don't introduce an unwanted reflection in the plane x = z.)
 
Ascendant0 said:
I tried grouping them similar to what I do with Plot3D, but it seems to only take one function when I set it up like I did above with Plot3D (for the 2 equations together in one command).
Hmm, worked for me.

Screenshot 2024-07-31 at 2.15.48 PM.png
 

Similar threads

Replies
5
Views
2K
Replies
3
Views
2K
Replies
1
Views
2K
Replies
0
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
1
Views
2K
Back
Top