Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm getting strange spikes in my surface S with the code below. PlotPoints seems to help, but it doesn't solve the problem. Any explanation and solution would be much appreciated.

a := {x, y, 1 - x}
b := {x, y, x}
S := Inner[Times, 
  Transpose[Inner[Times, {1 - x, x}, {{a /. {x -> 0, y -> 0}, b /. {x -> 0, y -> 1}},
     {a /. {x -> 1, y -> 0}, b /. {x -> 1, y -> 1}}}, Plus]], {1 - y, y}, Plus]
ParametricPlot3D[S, {x, 0, 1}, {y, 0, 1}]
ParametricPlot3D[S, {x, 0, 1}, {y, 0, 1}, PlotPoints -> 100]
Expand[S]
ParametricPlot3D[{x, y, 1 - x - y + 2 x y}, {x, 0, 1}, {y, 0, 1}]

EDIT: It seems that y -> is somehow responsible.

enter image description here enter image description here enter image description here

share|improve this question
    
I can't see your spikes with Mma 9.0 WinXP –  belisarius Apr 25 '13 at 18:24
1  
I can see them (9.0.1 on Mac) –  Michael E2 Apr 25 '13 at 18:26
    
Thanks for checking. I'm on Win8 with MMA 9.0.1. I briefely edited out the y -> 0 here because I thought it was redundant for my MWE. Now it's back in. It does matter in full code. Without y -> , I also don't get spikes. Strange. –  Frank Apr 25 '13 at 18:32
    
I can see spikes on Vista (Mathematica 9.0). Conclusions: Expand helps ? A related problem where Expand had helped in version 8.0 : mathematica.stackexchange.com/questions/3568/…. However that bug has been fixed in ver. 9.0. –  Artes Apr 25 '13 at 18:38
    
@Frank Same here –  belisarius Apr 25 '13 at 18:41

1 Answer 1

up vote 5 down vote accepted

The reason for the strange behavior is the "strange" definition of S. Compare:

Block[{x, y},
 x = 0.6; y = 0.4;
 S]
  (* {0.6, 0.4, 0.24} *)

S /. {x -> 0.6, y -> 0.4}
  (* {0.6, 0.4, 0.48} *)

Plot does something like the first one. What happens is that every x is replaced by 0.6 and every y is replaced by 0.4. So a = {x, 0, 1 - x} becomes {0.6, 0, 0.4}, and the rules {x -> 0, y -> 0} become {0.6 -> 0, 0.4 -> 0}. When applied to a, we get {0, 0, 0} instead of {0, 0 1}.

The following is a possible workaround:

ParametricPlot3D[Evaluate @ S, {x, 0, 1}, {y, 0, 1}]

[Edit: Forgot to put the Evaluate in.]

share|improve this answer
    
Thanks, much appreciated –  Frank Apr 25 '13 at 19:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.