2
$\begingroup$

I have the following function I want to plot in 3D (For simplicities sake we can say $a=5,b=-1,c=3$.)

f[x_, y_, a_, b_,c_] := ((E^(b x) - E^(b y)) x)/((c E^(a b) + E^(b x)) (x - y))

However, when I plot it I get error messages for Intermediate values. To try to solve this I used Exclusions, but despite this I still get the same error messages.

Plot3D[{f[x, y,5,-1,3]}, {x, 9, 10}, {y, 9, 10}, Exclusions -> {x - y == 0}]

I thought I should maybe exclude the values -0.1<=x-y<=0.1, but I don't really know how to do it or if it works. Another thought I had was maybe use the conditions that result from using reduce. However, I'm not sure how to use the results to exclude intermediate values.

Reduce[f[x, y,5,-1,3] == 0, x]

Any suggestions on other ways to do it would be greatly appreciated.

$\endgroup$
  • $\begingroup$ Why do you mind error messages ? Try e.g. Plot3D[{f[x, y, 5, -1, 3]}, {x, 9, 10}, {y, 9, 10}] // Quiet or if you need to exclude a region e.g. : Plot3D[{f[x, y, 5, -1, 3]}, {x, 9, 10}, {y, 9, 10},RegionFunction -> Function[{x, y, z}, Abs[x - y] > 0.1]] // Quiet $\endgroup$ – Artes Oct 2 '12 at 1:51
  • $\begingroup$ A simpler example: Plot3D[1/(x - y), {x, 9, 10}, {y, 9, 10}, Exclusions -> {x == y}]. Note that the message Power::infy only comes up once... $\endgroup$ – J. M. is in limbo Oct 2 '12 at 1:51
  • $\begingroup$ @Artes "Error message" might even be a misnomer, here. Maybe just a "warning" that something might be wrong, not necessarily that something is wrong. $\endgroup$ – Mark McClure Oct 2 '12 at 1:59
  • $\begingroup$ @Artes it's not that I don't mind the error messages, it's just that I'm using it in a presentation and don't want the graph to produce messages. $\endgroup$ – E.O. Oct 2 '12 at 2:44
  • $\begingroup$ @E.O. Quit just serves that purpose. $\endgroup$ – Artes Oct 2 '12 at 10:00
2
$\begingroup$

You can try using Quiet to suppress the message, or re-define the function to exclude the problem points in the function definition:

 f1[x_, y_, a_, b_, c_] := ((E^(b x) - E^(b y)) x)/((c E^(a b) + E^(b x)) (x - y)) /;
   x != y;
 f2[x_, y_, a_, b_, c_] := Switch[x == y, True,   Indeterminate, 
   _, ((E^(b x) - E^(b y)) x)/((c E^(a b) +  E^(b x)) (x - y))];



Row[{Plot3D[Quiet@f[x, y, 5, -1, 3], {x, 9, 10}, {y, 9, 10},
      BoxRatios -> 1, ImageSize -> 250], 
    Plot3D[f1[x, y, 5, -1, 3], {x, 9, 10}, {y, 9, 10}, 
     BoxRatios -> 1,  ImageSize -> 250], 
    Plot3D[f2[x, y, 5, -1, 3], {x, 9, 10}, {y, 9, 10}, 
     BoxRatios -> 1, ImageSize -> 250]}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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