Message Boards Message Boards

1
|
6792 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:
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
POSTED BY: Rob Holman
2 Replies
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} *)
POSTED BY: Arnoud Buzing
In[259]:= sol = Reduce[Abs[2 x - 1] <= 3, x, Reals]
Part[List @@ sol, {1, -1}]

Out[259]= -1 <= x <= 2
Out[260]= {-1, 2}
POSTED BY: Youngjoo Chung
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