Talk:Set of real numbers: Difference between revisions

From Rosetta Code
Content added Content deleted
(→‎Extra Credit?: Zero finding is big.)
Line 26: Line 26:
::Nevertheless, finding the zeros of an arbitrary computation has little to do with this task. The easiest way of solving the extra credit in a language that does not already implement the required zero finding involves manipulation of the underlying expressions by the programmer -- something that can be easier to do outside of the context of set notation. Though it's true that the set implementation might be used to determine which of the regions bounded by the zeros are in the set and which of those reason are outside of the set.
::Nevertheless, finding the zeros of an arbitrary computation has little to do with this task. The easiest way of solving the extra credit in a language that does not already implement the required zero finding involves manipulation of the underlying expressions by the programmer -- something that can be easier to do outside of the context of set notation. Though it's true that the set implementation might be used to determine which of the regions bounded by the zeros are in the set and which of those reason are outside of the set.
::Put differently, it's a modularity violation. Simple zero finding algorithms, like hill climbing, are going to be baffled by the interface provided by set membership -- there is no slope. So that pushes the implementation of this algorithm inside the set implementation. But zero finding becomes arbitrarily complex when presented with arbitrary computations. --[[User:Rdm|Rdm]] 10:48, 3 October 2011 (UTC)
::Put differently, it's a modularity violation. Simple zero finding algorithms, like hill climbing, are going to be baffled by the interface provided by set membership -- there is no slope. So that pushes the implementation of this algorithm inside the set implementation. But zero finding becomes arbitrarily complex when presented with arbitrary computations. --[[User:Rdm|Rdm]] 10:48, 3 October 2011 (UTC)

:::Actually, as written, the zero finding is part of the task, which I agree does seem like a large task in itself. Maybe the optional part of the task should be made easier?
:::How about the optional task being changed to a description of what the length ''is'', followed by "find the length of the set formaed by <combination of ~5 simple sets>" ? --[[User:Paddy3118|Paddy3118]] 16:10, 3 October 2011 (UTC)

Revision as of 16:10, 3 October 2011

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)

Unfortunately I can't hide under that excuse. I don't use Mathematica, and don't often use their web site. It just looked like in their list of information on what I input that they had decided to give two solutions rather than one solution that has two components. Looking again at their web page, they don't link the two - they actually separate them with a horizontal bar the first level of visual grouping that includes them both has the heading solutions.
Your output from the Mathematica program that you give above is quit explicit in showing one answer with two parts by its use of brackets. I live and learn. Thanks. --Paddy3118 11:57, 2 October 2011 (UTC)

Extra Credit?

What is the point of the extra credit? Finding length seems to have little to do with set membership. --Rdm 20:24, 2 October 2011 (UTC)

It's mostly for the usefulness of the set implementation in practice:
  1. The length sum is the set's Lebesgue measure, which gives you a sense of the set's size, analogous to number of elements in a countable set. It can be useful for numeric methods.
  2. If your set implementation allows a straightforward calculation of the length, the same method might be easily extended to do other things such as integrating a function over a set. The length of set A itself can be thought as integrating constant function f(x) = 1 for x in A.
  3. If for neither of the above, the optional goal can be used as a measure of efficiency of your implementation. It easily specifies a relative large number of continuous regions (100ish) that you need to deal with for the set arithmetic. --Ledrug 23:15, 2 October 2011 (UTC)
Nevertheless, finding the zeros of an arbitrary computation has little to do with this task. The easiest way of solving the extra credit in a language that does not already implement the required zero finding involves manipulation of the underlying expressions by the programmer -- something that can be easier to do outside of the context of set notation. Though it's true that the set implementation might be used to determine which of the regions bounded by the zeros are in the set and which of those reason are outside of the set.
Put differently, it's a modularity violation. Simple zero finding algorithms, like hill climbing, are going to be baffled by the interface provided by set membership -- there is no slope. So that pushes the implementation of this algorithm inside the set implementation. But zero finding becomes arbitrarily complex when presented with arbitrary computations. --Rdm 10:48, 3 October 2011 (UTC)
Actually, as written, the zero finding is part of the task, which I agree does seem like a large task in itself. Maybe the optional part of the task should be made easier?
How about the optional task being changed to a description of what the length is, followed by "find the length of the set formaed by <combination of ~5 simple sets>" ? --Paddy3118 16:10, 3 October 2011 (UTC)