Group Abstract Group Abstract

Message Boards Message Boards

0
|
6.8K Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Can you extract variables from a list of equations?

Posted 10 years ago

Given a list of equations (or inequalities) I wish to find all the variables in said list. Example:

{x >= 0, y >= 0, z >= 0, 2 x >= y, 2 z >= y, 2 x + y <= 4, 2 z + y <= 4};
-or-
{x1 >= 0, x2 >= 0, x3 >= 0, 2 x1 >= x2, 2 x3 >= x2, 2 x1 + x2 <= 4, 2 x3 + x2 <= 4}

This will generate:

{x,y,z}
-or
{x1,x2,x3}

Respectively. Ive tried to use Variables, however, Variables is only for expressions. Is this even possible?

POSTED BY: Conor Nelson
2 Replies
POSTED BY: Szabolcs Horvát

Try this:

list = {x1 >= 0, x2 >= 0, x3 >= 0, 2 x1 >= x2, 2 x3 >= x2, 2 x1 + x2 <= 4, 2 x3 + x2 <= 4} ;
Variables[Part[list,All,1]]
Variables[Apply[List,list,1]]

I.M.

POSTED BY: Ivan Morozov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard