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 need to plot a complex implicit function, ContourPlot in this case is not very convenient for me. Therefore, I want to plot my function using discrete points. I think this simple approach is convenient, both for me to understand and for those who I want to help. So let's plot the unit circle using ListPlot. I can do it in this way (I'm sure there is much simpler way):

y[x_] := y /. FindRoot[x^2 + y^2 == 1, {y, 0.01}]
data = Table[{x, y[x]}, {x, -1, 1, 0.1}]
y2[x_] := y2 /. FindRoot[x^2 + y2^2 == 1, {y2, -0.01}]
data2 = Table[{x, y2[x]}, {x, -1, 1, 0.1}]
ListPlot[{data, data2}, PlotStyle -> {Black, Black}, AspectRatio -> 1]

Now I want to set constraint on the solution of y, say y < 0.5. How could I do this by using Select?

share|improve this question

closed as off-topic by Kuba, Sjoerd C. de Vries, Yves Klett, rasher, Michael E2 Apr 27 at 23:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Kuba, Sjoerd C. de Vries, Yves Klett, rasher, Michael E2
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Like Select[data, #[[2]] < .5 &]? –  belisarius Oct 29 '13 at 6:52
    
Yes, that's what I need. Thanks a lot –  Knightq Oct 30 '13 at 1:55

1 Answer 1

This answer is partly based on belisarius' comment to the question.

Replace

data = Table[{x, y[x]}, {x, -1, 1, 0.1}]

with either

data = Table[If[y[x] < .5, {x, y[x]}], {x, -1, 1, 0.1}]

or

data = Select[Table[{x, y[x]}, {x, -1, 1, 0.1}], #[[2]] < .5 &]

Choosing the former because it is simpler, your code becomes

y[x_] := y /. FindRoot[x^2 + y^2 == 1, {y, 0.01}]
data = Table[If[y[x] < .5, {x, y[x]}], {x, -1, 1, 0.1}];
y2[x_] := y2 /. FindRoot[x^2 + y2^2 == 1, {y2, -0.01}]
data2 = Table[{x, y2[x]}, {x, -1, 1, 0.1}];
ListPlot[{data, data2},
  PlotStyle -> {Black, Black},
  PlotRange -> {Full, {-1., 0.5}},
  PlotRangePadding -> 0.05,
  AspectRatio -> Automatic]

and produces this output:

plot

share|improve this answer

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