Message Boards Message Boards

0
|
5733 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

ContourPlot3D question

Can anyone tell me why the first two ContourPlot3D calls don't work, but the third one does?
 In[119]:= Clear["Global`*"]
 
 In[120]:= A = {{1, 0, 5}, {-2, 1, -6}, {0, 2, 8}};
 b = {2, -1, 6};
 
 In[122]:= Thread[A.{x1, x2, x3} == b]
 Out[122]= {x1 + 5 x3 == 2, -2 x1 + x2 - 6 x3 == -1, 2 x2 + 8 x3 == 6}
 
 In[123]:= ContourPlot3D[%, {x1, -10, 10}, {x2, -10, 10}, {x3, -10, 10}]
Out[123]= ContourPlot3D[%, {x1, -10, 10}, {x2, -10, 10}, {x3, -10, 10}]

In[124]:= ContourPlot3D[
Thread[A.{x1, x2, x3} == b], {x1, -10, 10}, {x2, -10, 10}, {x3, -10,
  10}]
Out[124]= ContourPlot3D[
Thread[A.{x1, x2, x3} == b], {x1, -10, 10}, {x2, -10, 10}, {x3, -10,
  10}]

In[125]:= ContourPlot3D[{x1 + 5 x3 == 2, -2 x1 + x2 - 6 x3 == -1,
  2 x2 + 8 x3 == 6}, {x1, -10, 10}, {x2, -10, 10}, {x3, -10, 10}]
POSTED BY: Betty Love
3 Replies
Yes, Thread is not necessary (though it gives a nice speed up).

In the examples with (unevaluated) Thread or (unevaluated) %, ContourPlot3D doesn't know it has been given equation(s), and it can't work with a function that evaluates to non-numerical values.
POSTED BY: Ilian Gachevski
Thanks! That works.

Based on your explanation, I don't need the Thread, right?  It works without it.

So is it actually internally doing some iteration over values of x1, x2, and x3 in their given ranges; each time plugging those values into A.{x1, x2, x3} == b to get True or False in order to build the plot?
POSTED BY: Betty Love
From the documentation, "ContourPlot3D has attribute HoldAll and evaluates f and g only after assigning specific numerical values to x, y, and z".

In this case, when x1, x2, x3 have numerical values, first A.[x1, x2, x3] == b evaluates to False (or True), and then Thread does nothing.

Try
ContourPlot3D[Evaluate[Thread[A.{x1, x2, x3} == b]], {x1, -10, 10}, {x2, -10, 10}, {x3, -10, 10}]
POSTED BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract