Talk:Set of real numbers

From Rosetta Code

Not making this a draft task yet: anyone see glaring problems? --Ledrug 04:32, 30 September 2011 (UTC)

Looks fine to me; I've marked as a draft. The only thing I'd note is that I wouldn't require the creation of a datatype; that's just one way of doing it — a particular abstraction, if you will — that not all languages would choose to do (for example, you could write a turing machine description which would do the operations, but which would not have datatypes, as it doesn't have those abstractions). That's really a minor quibble though. –Donal Fellows 09:57, 30 September 2011 (UTC)
The optional task seems to require a particular implementation. To do the compulsory part, a set could be represented by a boolean expression, and the set arithmatic by and, or or'ing the boolean expressions of input sets to create a boolean expression for the output set. Testing a number for inclusion would involve evaluation the boolean expression. I am unsure of the details of what the optional part requires, but if it needed the calculation of the sum of the range of all numbers included in the set then that ... ...may take extra thought. (Nice subject for a task though). --Paddy3118 11:00, 30 September 2011 (UTC)
A set over real domain is uncountable, so you definitely can't test insideness of individual numbers and sum the count. I specifically mentioned convex sets (simple ranges) because that's the most likely building block of more complex sets, and if you go that route, total length of a set is just the sum of all its contained non-overlapping range lengths.
@Dkf: I'll reword the datatype thing. --Ledrug 11:16, 30 September 2011 (UTC)
This depends on an implementation for "real numbers" and it's not clear whether floating point is considered adequate in this role. --Rdm 17:57, 30 September 2011 (UTC)

Wolfram Mathworld and Perl

I copied one of the equations, |sin(pi x2)| > 1/2, 0 < x < 10 into mathworld and got the result:

sqrt(12 * n + 1) / sqrt(6) < x < sqrt(12 * n + 5) / sqrt(6), 0 <= n <= 49

For n = 49 I get the range component: (9.9079092984679, 9.941495528004495) which differs from the Perl: (9.96, 9.99). --Paddy3118 07:04, 2 October 2011 (UTC)

Aren't there two sets of solutions? --Ledrug 07:32, 2 October 2011 (UTC)
I took the two solutions as meaning that there were two ways of expressing the same thing rather than being parts of a whole as they use the word solutions plural. I've just checked and the other does give (9.958246164193104, 9.991663191547909), so all seems well. --Paddy3118 07:47, 2 October 2011 (UTC)
Er I'll pretend this is an American/British English thing, but does it mean "x^2 = 1 has two solutions: x = 1, x = -1" is counterintuitive? Also if you are familiar with Mathematica, you would have seen the composite solutions all the time:<lang>In[1]:= Solve[x x == 1, {x}]

Out[1]= {{x -> -1}, {x -> 1}}</lang> It's not supposed to repeat the same solution in a equivalent but different form. --Ledrug 07:59, 2 October 2011 (UTC)