Friday, June 23, 2017

Digest for comp.lang.c++@googlegroups.com - 9 updates in 3 topics

JiiPee <no@notvalid.com>: Jun 23 08:24PM +0100

On 17/06/2017 22:38, Richard Damon wrote:
> permanent storage, and perhaps updated by specific actions.
 
> A second chunk of data is for a player in a particular game. This data
> would need to know what player it relates to and
 
Ye data related only to a game. But how would you name that class?
Player? How would you name the persons permanent detail class? Person?
Or PlayerInGame/Player?
 
 
> A last chunk of data would be a historical record. When the game is
> over, a summary of how they did is stored in permanent storage, and
> that data is likely never changed thereafter.
 
Ye I do store all the players game information/rating in a file already.
ID is the players (sing in-) name.
JiiPee <no@notvalid.com>: Jun 23 08:29PM +0100

On 17/06/2017 09:17, Öö Tiib wrote:
> in game then that for example can make all the checks and handling like
> if(player.current_game == NULL) unneeded. That*is* keeping it simpler.
> No?
 
 
The way I do is that all players are read first in a vector. Then when
game starts I create another vector and copy the players there from the
first vector who want to play.
 
 
but true to be perfect the game data better to isolate from persons details
me <crisdunbar@gmail.com>: Jun 22 05:48PM -0700

On Thursday, June 22, 2017 at 3:07:31 PM UTC-7, Chris Vine wrote:
 
> Thank you, that is a curiosity. This presumably arises from the fact
> that rationals are expressible by two integers (as a fraction), two
> being a finite number, but it is still somewhat counter intuitive.
 
I'm not a mathematician by any stretch, so I'm mostly just musing here:
 
I'm sure a real mathematician would quibble about your "arises from"
explanation, but I think it's not unreasonable in a hand-wavey manner.
 
I think the algebraics extend your explanation in an interesting way.
Just like the rationals can be defined by _pairs_ of integers, the
algebraics can be defined by tuples (of finite but unbounded degree)
of integers and so form a countable set (i.e., have the same
cardinality as the naturals). But the algebraics include
many _irrational_ numbers as well, though though of course "many"
means "almost none" of the reals =)
Gareth Owen <gwowen@gmail.com>: Jun 23 05:57AM +0100

>> (the smallest - they are both countably infinite).
 
> Are you agreeing with me, disagreeing with me, or adding verisimilitude
> and corroborative detail?
 
I think I'm disagreeing with you, because I *think* you suggested there
were more rationals than reals.
 
> As I understand it the cardinality of reals is at least as large as
> that of naturals (integers), the cardinality of naturals being the
> minimum infinite cardinality.
 
True. You can't put the reals and integers into one-to-one
correspondence (diagonal-slash argument).
 
You *can* put the rationals and integers into one-to-one correspondence
so their cardinalities are the same.
Paul Sinnett <paul.sinnett@gmail.com>: Jun 23 04:57AM -0700

On Friday, 23 June 2017 05:58:07 UTC+1, gwowen wrote:
> correspondence (diagonal-slash argument).
 
> You *can* put the rationals and integers into one-to-one correspondence
> so their cardinalities are the same.
 
True, but I think this branch of the thread has gone into the weeds because it left the world of c++ types and entered the world of mathematical sets.
 
A better comparison for the intended context would be 16 bit integers compared with 32 bit integers. The second can represent all of the first and then some.
 
Although as an interesting aside without leaving a purely programming world: while a rational type made from two 32 bit integers can represent less distinct values than a 64 bit fixed point number made from 2 32 bit integers, it can still represent values exactly (e.g. 1/3) that the fixed point cannot.
David Brown <david.brown@hesbynett.no>: Jun 23 01:58PM +0200

On 23/06/17 02:48, me wrote:
>> that rationals are expressible by two integers (as a fraction), two
>> being a finite number, but it is still somewhat counter intuitive.
 
> I'm not a mathematician by any stretch, so I'm mostly just musing here:
 
I am a mathematician by education, but a engineer by profession.
Hopefully that is good enough :-)
 
> I'm sure a real mathematician would quibble about your "arises from"
> explanation, but I think it's not unreasonable in a hand-wavey manner.
 
It is not a bad way to think about it, IMHO.
 
When talking about the cardinality ("size") of infinite sets, and
comparing the size of sets A and B, you can prove them equal in two
ways. One is to figure out a bijection between them - a function "f"
that takes every "a" from "A" and maps it to exactly one "b" in "B",
covering the whole of B. The other is to find two /injections/ - a
function that takes every "a" from "A" and maps it to exactly one "b" of
"B" (but not necessarily covering all of B), and vice-versa.
 
An injection from the integers to the rationals is easy - every integer
is already a rational. Thus there are at least as many rationals as
integers.
 
To go the other way, think of your rationals as p/q where p and q are
integers (with q non-zero). Draw two axis, with p as the horizontal
axis and q as the vertical axis. Each point on this grid is a rational
p/q. Note that each rational turns up in many places - ½ will be at (1,
2), (2, 4), (-100, -200), etc. That doesn't matter. If you start at
the middle and move around the grid in a square spiral, you will pass
through each point in the grid in a finite time. For each rational, the
corresponding integer is then the distance you have gone in your spiral.
Thus there are no more rationals than there are integers.
 
For any given infinite cardinal ∞, and any finite integer n, there are
some odd rules of arithmetic that arise from arguments like this:
 
∞ + n = n + ∞ = ∞
∞ * n = n * ∞ = ∞
∞ + ∞ = ∞
∞ * ∞ = ∞
∞ ^ n = ∞
 
(But beware : n ^ ∞ ≠ ∞)
 
So combining two integers to get the rationals gives you ∞², which is
the same as ∞. (2^∞ is much bigger - it is the size of the real numbers.)
 
> cardinality as the naturals). But the algebraics include
> many _irrational_ numbers as well, though though of course "many"
> means "almost none" of the reals =)
 
(For those that don't know, algebraic numbers are the solutions to
equations of the form a₀ + a₁·x + a₂·x² + … + a_n·x^n = 0, where n is a
finite positive integer, and all the coefficients are integers. They
are a subset of the complex numbers.)
 
It is not really accurate to describe the algebraic numbers as a set of
tuples, because there is no fixed size for the tuples. You could say it
is the union of a set of sets of tuples.
 
Proving that there are no more algebraic numbers than there are
integers, despite there being no finite limit on how long the tuples
are, is more interesting than proving the size of the rationals.
Ben Bacarisse <ben.usenet@bsb.me.uk>: Jun 23 03:02PM +0100

> axis and q as the vertical axis. Each point on this grid is a rational
> p/q. Note that each rational turns up in many places - ½ will be at (1,
> 2), (2, 4), (-100, -200), etc. That doesn't matter.
 
It doesn't matter but it does mean you need to adjust the text above
since what you end up describing here:
 
> through each point in the grid in a finite time. For each rational, the
> corresponding integer is then the distance you have gone in your spiral.
> Thus there are no more rationals than there are integers.
 
is not an injection. Unless, of course, by "for each rational" you mean
"for each unique rational" in which case the spiral gives you a
bijection and you don't need to "two injections" approach.
 
Since you are looking only for an injection you can map p/q (in its
lowest form) to 2^p3^q and, if you need to map the negative rationals,
map -p/q to, say, 5^p3^q.
 
<snip>
>> I think the algebraics extend your explanation in an interesting way.
 
<snip>
> (For those that don't know, algebraic numbers are the solutions to
> equations of the form a₀ + a₁·x + a₂·x² + … + a_n·x^n = 0, where n is a
> finite positive integer, and all the coefficients are integers.
 
<snip>
> Proving that there are no more algebraic numbers than there are
> integers, despite there being no finite limit on how long the tuples
> are, is more interesting than proving the size of the rationals.
 
You can use the same prime power injection or simply sort the
polynomials using the normal sort order.
 
--
Ben.
David Brown <david.brown@hesbynett.no>: Jun 23 04:29PM +0200

On 23/06/17 16:02, Ben Bacarisse wrote:
 
> is not an injection. Unless, of course, by "for each rational" you mean
> "for each unique rational" in which case the spiral gives you a
> bijection and you don't need to "two injections" approach.
 
Yes, it is an injection from each pair of integers (or grid point) to
the integers, rather than an injection from the rationals. And an
injection from each rational to the grid can be made by taking the point
corresponding to the lowest form of p/q. So really, I should have given
it as a two-step process - so much for trying to keep it simple!
 
> Since you are looking only for an injection you can map p/q (in its
> lowest form) to 2^p3^q and, if you need to map the negative rationals,
> map -p/q to, say, 5^p3^q.
 
Or alternatively, to 5 * 2^p * 3^q.
 
There are many ways to make such injections. A visual one with a spiral
is often easier to comprehend, but messier for calculations and rigorous
proof.
 
>> are, is more interesting than proving the size of the rationals.
 
> You can use the same prime power injection or simply sort the
> polynomials using the normal sort order.
 
Yes, mapping the polynomial to 2^a₀ + 3^a₁ + 5^a₂ + … works nicely.
Again, there are a number of ways of doing it.
 
(And like the case of the rationals, this is an injection from the
integer polynomials to the integers, not an injection from the algebraic
numbers. Each algebraic number is the solution to infinitely many such
polynomials.)
ram@zedat.fu-berlin.de (Stefan Ram): Jun 23 12:38AM

>For example, there is the relationship between mathematical ?integer?
>and ?rational?, where every integer value is-a rational value, but where
>there are more rationals...
 
In mathematics, a real number is a complicated structure
based on nested intervals (or defined in some similar way¹).
That also applies to the real number »1«. So, one cannot
immediately assume that this is the same thing as the natural
number »1« of the Peano axioms. But one can define a
»natural injection« from the natural numbers into the
real numbers.

¹ e.g., en.wikipedia.org/wiki/Surreal_number
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: