Message Boards Message Boards

0
|
1747 Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Problem with plotting Sign[ ]: unexpected output

Posted 2 years ago

Hello,

1) I want to plot the sign of the square root of some function. One expects to obtain values {1} and {0} in the domain where the expression under the square root is positive or zero respectively. In addition to that, I have several pieces on the plot with values continuously ranging from -1 to 1. What is it and how can one avoid that?

The second question is similar.

2) I want to plot the sign of a quite complicated function. But in addition to domains with values {-1,0,1} I have a contribution with value continuously ranging from -1 to 1. What is it and how can one avoid that?

The notebook is enclosed.

Attachments:
POSTED BY: Ilya Shabat
4 Replies

The sign seems to be zero only in a meager set. I would plot directly the value 1 with a RegionFunction:

Plot3D[1, {x, 0, 2 \[Pi]}, {y, 1, 5}, 
 RegionFunction -> 
  Function[{x, y}, (1 - 2 y Cos[x])/(1 - y Cos[x]) > 0], 
 PlotPoints -> 50]
POSTED BY: Gianluca Gorni
Posted 2 years ago

And the function

Sqrt[((1 - 2 y Cos[x])/(1 - y Cos[x]))

is complex for parts of the range plotted. RealSign does not work for complex numbers.

POSTED BY: Rohit Namjoshi
Posted 2 years ago

Thank you! I even remember reading about this :)

POSTED BY: Ilya Shabat
Posted 2 years ago

Thank you a lot! RegionFunction works perfectly for the square root case. In the second case, I added PlotPoints -> 70 and achieved the desired result.

POSTED BY: Ilya Shabat
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