1
|
7035 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
GROUPS:

# How to select outer bounds of an inequality for use?

Posted 11 years ago
 Hi all:As a basic example, take:Reduce[Abs[2 x - 1] <= 3, x, Reals]This produces a range of values from -1 to 2.  I'd like to "pick" the bounds of this interval and use them in a successive calculation.  In particular, I'd like some code that would have the computer choose those values automatically, given any such range, similar to how list[[1]] would automatically choose the first item of any arbitrary list.Any suggestions?  Thanks for the help!Rob
2 Replies
Sort By:
Posted 11 years ago
 In[259]:= sol = Reduce[Abs[2 x - 1] <= 3, x, Reals]Part[List @@ sol, {1, -1}]Out[259]= -1 <= x <= 2Out[260]= {-1, 2}
Posted 11 years ago
 In this case you could change the inequality to an equality and then use Cases to extract the end points:solution = Reduce[Abs[2 x - 1] == 3, x, Reals](* Gives: x == -1 || x == 2 *)Cases[solution, x == num_ :> num](* Gives: {-1, 2} *)