Set theory on HP Prime
05-07-2014, 02:01 AM
Post: #1
 norlesh Junior Member Posts: 31 Joined: May 2014
Set theory on HP Prime
Hi all,
Does the prime have any facilities for dealing with sets such as union, difference, equality and such?
for example in PSUDOCODE:

{1, 2, 3} Union {2, 4, 5} = {1, 2, 3, 4, 5}
{1, 2, 3} Intersection {2, 4, 5} = {2}
{1, 2, 3} == {2, 1, 3} == TRUE
...
05-07-2014, 02:58 AM
Post: #2
 norlesh Junior Member Posts: 31 Joined: May 2014
RE: Set theory on HP Prime
Reading the Xcas documentation here and there is a full section on sets - tried using a similar syntax but the prime doesn't know what I'm on about. >;|
05-07-2014, 06:57 AM
Post: #3
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: Set theory on HP Prime
Sets are supported: the infix operators are union, minus, intersect, and you should use set[ ] instead of {} or [ ] to avoid confusion with lists/vectors, e.g. for ==
set[1,2]==set[2,1]
[1,2]==[2,1]
05-07-2014, 12:35 PM (This post was last modified: 05-07-2014 12:37 PM by norlesh.)
Post: #4
 norlesh Junior Member Posts: 31 Joined: May 2014
RE: Set theory on HP Prime
I just tried evaluating the following in the home screen

set[1,2]==set[2,1] ... result 1
set[1,2]==set[2,1,5] ... result 1 // WTF?

am I not understanding set theory correctly?

also every time set[..] gets evaluated it turns into set(..)
and 'set(1,2) union set(2, 1, 5)' gives a syntax error... is there any documentation?
05-07-2014, 02:53 PM
Post: #5
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: Set theory on HP Prime
Just tried on my emulator, set[1,2]==set[2,1,5] correctly returns 0 here and set[] are not converted to set(), so perhaps this is a UI bug that has been fixed.
05-07-2014, 03:43 PM
Post: #6
 Helge Gabert Senior Member Posts: 467 Joined: Dec 2013
RE: Set theory on HP Prime
(05-07-2014 06:57 AM)parisse Wrote:  Sets are supported: the infix operators are union, minus, intersect, and you should use set[ ] instead of {} or [ ] to avoid confusion with lists/vectors, e.g. for ==
set[1,2]==set[2,1]
[1,2]==[2,1]

Good to know! By the way, minus and union don't seem to appear in the toolbox catalog (intersect is in there, though).
05-07-2014, 03:48 PM
Post: #7
 Alberto Candel Member Posts: 169 Joined: Dec 2013
RE: Set theory on HP Prime
I have also tried out the commands mentioned by Parisse and they work correctly in CAS, but result in syntax error in Home.

A.
05-07-2014, 06:04 PM
Post: #8
 norlesh Junior Member Posts: 31 Joined: May 2014
RE: Set theory on HP Prime
Thanks guys - so I ran it under the CAS screen and can now confirm that set[1 2]==set[2 1 5] does indeed evaluate to zero... yey I don't have to learn a new formulation of set theory

{ just to be clear though it's definately still mutzed under the home screen as of the current firmware running on a physical device - I had no idea the calculators split brain disorder ran so deep!}
05-07-2014, 06:14 PM
Post: #9
 Alberto Candel Member Posts: 169 Joined: Dec 2013
RE: Set theory on HP Prime
(05-07-2014 03:43 PM)Helge Gabert Wrote:
(05-07-2014 06:57 AM)parisse Wrote:  Sets are supported: the infix operators are union, minus, intersect, and you should use set[ ] instead of {} or [ ] to avoid confusion with lists/vectors, e.g. for ==
set[1,2]==set[2,1]
[1,2]==[2,1]

Good to know! By the way, minus and union don't seem to appear in the toolbox catalog (intersect is in there, though).

There are the standard math symbols for union and intersection in the Chars list, but they do not work as such.
05-07-2014, 07:13 PM
Post: #10
 Alberto Candel Member Posts: 169 Joined: Dec 2013
RE: Set theory on HP Prime
The HP Prime never ceases to tease me. In CAS, if I type
[1,2,3] union [2,5]
in the command line, it displays (correctly)
union( [1,2,3], [2,5]) [1,2,3,5]

But if I enter directly
union( [1,2,3], [2,5])
in the command line, it reports syntax error.
05-08-2014, 07:03 AM
Post: #11
 parisse Senior Member Posts: 1,322 Joined: Dec 2013
RE: Set theory on HP Prime
This is a textbook mode display bug, if you uncheck it in Settings, it's ok.
 « Next Oldest | Next Newest »