Is it possible to delete a blog from the "I read these blogs" list?
new article, "A Romp Through Infinity"
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > Perl web-programming > new article, "A Romp Through Infinity" 8 August 2008 17:08:14

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

new article, "A Romp Through Infinity"

John M. Dlugosz 8 August 2008 17:08:14
 This weekend I wrote <http://www.dlugosz­.com/Perl6/web/Infin­ity_romp.html> which
explains the Inf features of Perl 6, but drills down each example to reach the
most fundamental language features, which it explains.

It should be interesting to those just taking the plunge to Perl 6 because so
many features are present in the smallest code fragment. For experts, look at
the final section where I point out things in the ongoing design that need work.
These examples identify things missing from the Synopses, etc.

Please let me know if you see any coding errors, and of course any feedback is
welcome.

--John
Add comment
TSa 5 August 2008 17:30:35 permanent link ]
 HaloO,

John M. Dlugosz wrote:
Please let me know if you see any coding errors, and of course any
feedback is welcome.

Firstly, shouldn't there also be infinite strings? E.g. 'ab' x Inf
is a regularly infinite string and ~pi as well. Other classes might
have elaborate notions of infinity. The Complex e.g. might have an
angle associated to an Inf.

Secondly, you only have a single Inf constant and its negation. But
there should be a multitude of infinities. E.g. a code fragment

my Int $a = random(0..1) > 0.5 ?? 3 !! Inf;
my Int $b = $a + 1;
say "yes" if $b > $a;

should always print "yes". That is we continue counting after Inf such
that we have transfinite ordinals.

0, 1, 2, ..., Inf, Inf+1, Inf+2, ..., Inf*2, Inf*2+1, ...

The implementation is strait forward as an array of coefficients
of the Inf powers with Inf**0 == 1 being the finite Ints. The sign
bit goes separate from the magnitude. That is you can do the usual
Int arithmetic in the ranges Inf..^Inf*2 and -Inf*2^..-Inf except
that Inf has no predecessor and -Inf no successor. Well, and we lose
commutativity of + and *. I.e. 1 + $a != $a + 1 if $a is transfinite.

I'm not sure if such a concept of "interesting values of infinity"
is overly useful, though. In TeX e.g. there are infinitely stretchable
spacings of different infinitudes so that they overwrite each other.
Or take a stereographic projection near the point opposite of the
center of projection where you can usefully clip instead of getting
into funny folding of values into the valid range.

Also I think we can have finite conceptual infinities for types like
int32 and num64. In the latter case we also have infinitely small
values and "infinities" like sqrt(2). In short everything that falls
out of the finite range of these types and is captured in Int or Num.
BTW, with an infinite precision Num I see no need for the Rat type!


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
TSa 6 August 2008 19:20:37 permanent link ]
 HaloO,

I wrote:
That is you can do the usual
Int arithmetic in the ranges Inf..^Inf*2 and -Inf*2^..-Inf except
that Inf has no predecessor and -Inf no successor. Well, and we lose
commutativity of + and *. I.e. 1 + $a != $a + 1 if $a is transfinite.

Well, we can of course count downwards from Inf to Inf-1, Inf-2, etc.
That is we don't have a global sign but signed coefficients with the
highest multiple of Inf determining the side of Zero we are on.

For the Num type we also might consider reciprocals of Inf as
infinitesimals. The only thing we need to define then is at which
points in computations these hypernums are standardized back into
Num ;)


An application for transfinite Ints is if you have two "infinite" files
concatenated into one. Then you can keep transfinite indices into the
second one. The size of such a file would be Inf*2 of course.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
John M. Dlugosz 7 August 2008 07:33:20 permanent link ]
 TSa Thomas.Sandlass-at-­barco.com |Perl 6| wrote:
Firstly, shouldn't there also be infinite strings? E.g. 'ab' x Inf
is a regularly infinite string and ~pi as well. Other classes might
have elaborate notions of infinity.
A string whose length is Inf is not itself equal to Inf. But $s.chars >
$b would be true for all normal values of the Num b.


The Complex e.g. might have an
angle associated to an Inf.
I think there are too many different ways of doing that to make it built
in. Normal Complex numbers are not ordered. But as described, a
complex number "but Inf" will still be greater than any normal complex
number.

Just as real numbers are pretty basic, you can add Inf to that domain to
form *"affinely extended real number system", which is what I think the
IEEE floats model a finite precision subset of. But there are many ways
to extend the basic, and someone using such a system would need to use a
module or define his own to get the exact behavior wanted.*


Secondly, you only have a single Inf constant and its negation. But
there should be a multitude of infinities. E.g. a code fragment
my Int $a = random(0..1) > 0.5 ?? 3 !! Inf;
my Int $b = $a + 1;
say "yes" if $b > $a;
should always print "yes". That is we continue counting after Inf such
that we have transfinite ordinals.
0, 1, 2, ..., Inf, Inf+1, Inf+2, ..., Inf*2, Inf*2+1, ...
Inf + $n == Inf for all real numbers $n. You don't get different
infinities that way. Likewise for multiplication: 2*Inf or even Inf**2
is still the _same_ value Inf.

The proposed Infinite class (see the thread I started on 4/25/2008) does
handle transfinite cardinals. Nothing in the P6 standard library cares
whether you mean the number of integers or the number of real numbers
etc. except for comparing Infinite values directly. But basic support
is available for that in the class, and more specialized applications
can write functions that use those values or extend the class to the
desired domain.





The implementation is strait forward as an array of coefficients
of the Inf powers with Inf**0 == 1 being the finite Ints. The sign
bit goes separate from the magnitude. That is you can do the usual
Int arithmetic in the ranges Inf..^Inf*2 and -Inf*2^..-Inf except
that Inf has no predecessor and -Inf no successor. Well, and we lose
commutativity of + and *. I.e. 1 + $a != $a + 1 if $a is transfinite.
What?

A power series of Inf is just the same Inf.
Were you trying to remember something concerning a power _set_?



I'm not sure if such a concept of "interesting values of infinity"
is overly useful, though. In TeX e.g. there are infinitely stretchable
spacings of different infinitudes so that they overwrite each other.

That kind of light-duty use (not mathematically rigorous but easy to
represent TeX's two springs) is why I included transfinite ordinals in
the class.

Also I think we can have finite conceptual infinities for types like
int32 and num64. In the latter case we also have infinitely small
values and "infinities" like sqrt(2). In short everything that falls
out of the finite range of these types and is captured in Int or Num.
The domain of int32 is a finite subset of \mathbb{Z}. If you want to
reserve some of the bit representations to mean other things, define
another type. The point of the lower-case types is to do the native CPU
stuff.

num64, assuming IEEE semantics, will include special values for + and -
Inf and for underflows like you indicate. I suppose that the
implementation of Num will use the underlying bit representations when
you convert Inf to Num. The Int type also is defined as being able to
represent + and - Inf, and the implementation will need to flag it as
such, somehow.



BTW, with an infinite precision Num I see no need for the Rat type!
The Num type is not infinite precision, but the highest-precision native
type that operates at full speed. Since there are high or arbitrary
precision float libraries available now, I'm sure CPAN6 will include some.



--John
Add comment
John M. Dlugosz 7 August 2008 17:19:08 permanent link ]
 TSa Thomas.Sandlass-at-­barco.com |Perl 6| wrote:
As I recall, it can handle the concept of Inf-1 etc.
Yes. But the Hyperreals do the same and stay within the realm
of set theory.

I'm not sure. A quick reading indicates that contains "infinitely large"
numbers that maintain the properties of addition, but that is not the same as
"infinity".

my @evenodd = 0..Inf:by(2), 1..Inf:by(2);
can be indexed as follows
say @evenodd[3]; # 6
say @evenodd[Inf+1]; # 3
say @evenodd[^3]; # 0 2 4
say @evenodd[Inf «+« ^3]; # 1 3 5
Even in the finite case one has to know the index where the transition
from even to odd is made. In the infinite case this point has the nice
name Inf that's all. Good question is if one can expect
say substr('ab' x Inf ~ 'ba' x Inf, Inf-1, Inf+1);
to print 'bb' on the rational that the structure is 'ab...abba...ba'

That's just not the way works.

I agree that the length of your file comprehension could be some number that is
in that is "infinitely large" and not in regular , but it will still be less
than . In order to have +1 and -1 make sense, it needs to be some specific
"infinitely large" integer, not the generic singularity of Inf.

In any case, the fact that there are so many different systems is a reason why
you should be free to choose a module and not have it built in. If you, for
example, C< use Conway::Surreal; >, then it could export new meanings of
infix:<+> between Inf and Num and return a Surreal number.

With the core of the
language mandating the Inf type every programmer must be aware of
potentially infinite loops etc.

The programmer should be aware of how Inf behaves in comparisons and arithmetic.
And the rule is that x: x , +x= .

--John
Add comment
Xavier Noria 7 August 2008 17:49:28 permanent link ]
 On Thu, Aug 7, 2008 at 3:19 PM, John M. Dlugosz
<dhcgnd702@sneakema­il.com> wrote:

I'm not sure. A quick reading indicates that contains "infinitely large"
numbers that maintain the properties of addition, but that is not the same
as "infinity".

Well *R is a field that has infinitely large and small numbers and
contains R. Surreal numbers are in turn kind of a completion of
ordinals. You can complete de complex plane with a single infinity
point....

IMO to include something related to infinity you need to stick with
some particular model and forget the rest.
Add comment
TSa 7 August 2008 18:04:27 permanent link ]
 HaloO,

John M. Dlugosz wrote:
The proposed Infinite class (see the thread I started on 4/25/2008) does
handle transfinite cardinals.

Do you mean the thread called "The Inf type" where I replied to your
post of a version of your specdoc? My concern with the approach you take
there is to base it on cardinals whereas ordinals are much more
practical. The .elems of an array for example should be its order type
not its size as a cardinal. For hashes the size is a cardinal, though.
But an infinite hash would need infinitely many keys. So a safe bet is
that all hashes will be finite and finite cardinals are equal to finite
ordinals.


BTW, with an infinite precision Num I see no need for the Rat type!
The Num type is not infinite precision, but the highest-precision native
type that operates at full speed. Since there are high or arbitrary
precision float libraries available now, I'm sure CPAN6 will include some.

Could we get confirmation for that from @Larry. I remember $Larry
mentioning that Num fails over to Rat or so when necessary. IOW,
does

my Rat $rat = 1/3; # assuming infix:</> returns a Rat
my Num $num = 1/3;

my Rat $diff = abs($rat - $num);

store a non-zero value in $diff? I assume that Num is discrete with a
binary representation and infix:<->:(Rat,Num-­->Rat) converts $num to a
fraction with a power of two in the denominator. BTW, with floor
semantics I would expect $num < $rat.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
Mark A Biggar 7 August 2008 19:29:07 permanent link ]
 Supporting multiple levels of infinities, transfinite numbers or even Surreal Numbers should be considered in the same category of features as returning multiple answers from complex trig functions.

They're an interesting thing to discuss and experiment with but shouldn't distract form getting Perl 6 out the door. Let's just make sure we're handling inf and -inf right and leave all that other stuff until later.

--
Mark Biggar
mark@biggar.org
mark.a.biggar@comca­st.net
mbiggar@paypal.com
Add comment
Will Coleda 7 August 2008 19:31:08 permanent link ]
 On Thu, Aug 7, 2008 at 11:29 AM, <mark.a.biggar@comc­ast.net> wrote:
Supporting multiple levels of infinities, transfinite numbers or even Surreal Numbers should be considered in the same category of features as returning multiple answers from complex trig functions.
They're an interesting thing to discuss and experiment with but shouldn't distract form getting Perl 6 out the door. Let's just make sure we're handling inf and -inf right and leave all that other stuff until later.

+1

--
Mark Biggar
mark@biggar.org
mark.a.biggar@comca­st.net
mbiggar@paypal.com



--
Will "Coke" Coleda
Add comment
TSa 7 August 2008 20:01:46 permanent link ]
 HaloO,

Xavier Noria wrote:
IMO to include something related to infinity you need to stick with
some particular model and forget the rest.

Well spoken. But I think that the model John has chosen is a bit
too restrictive. If a type has a notion of Zero it could have a
similar notion of infinity just at "the other side". For the Int
type in a two's complement mindset that means that counting through
the Ints in increasing order from zero is the same as going in
the *same* direction from -Inf where Zero is the unreachable infinity.
Here I assume that both Zero and -Inf are represented as the infinite
string of 0 binary digits. One is little endian the other big endian,
though. If you don't know where you are in your infinite sequence of
0 then Zero is indistinguishable from -Inf and -1 is indistinguishable
from +Inf, both are infinite sequences of 1.

E.g. +('9' x Inf) == -1 could be a true comparison that doesn't
even scratch the memory resources of temporary hardware. With the
above in mind we could e.g. also define ^-4 === -4..-1 most
conveniently as (*-4)..(*-1) for array indexing from the back in
forward order. Or perhaps that is ^(*-4) and the ^-4 is for indexing
in front of the array. The Whatever type is also behaving a bit like
Inf because it represents different numbers in different arrays.
That is

my Whatever of Int $idx = -4;

always indexes arrays from the back but behaves like normal -4 when
no special handling is required, IOW it sets the shift to zero. Note
that infix:<op>:(Whateve­r[::X],X-->Whatever[X]) but infix:<op>:(::X,
Whatever[X]-->X) are sort of non-commutative. Note that the default
value for Whatever is Inf ;)


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
TSa 7 August 2008 20:25:34 permanent link ]
 HaloO,

mark.a.biggar@comca­st.net wrote:
Let's just make sure we're handling inf and -inf right and leave all
that other stuff until later.

The point is: what is the minimum we need to be future proof
and compatible to other language features.

Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
John M. Dlugosz 8 August 2008 11:45:35 permanent link ]
 Xavier Noria fxn-at-hashref.com |Perl 6| wrote:
IMO to include something related to infinity you need to stick with
some particular model and forget the rest.

I couldn't have said it any better.

Add comment
John M. Dlugosz 8 August 2008 11:49:50 permanent link ]
 TSa Thomas.Sandlass-at-­barco.com |Perl 6| wrote:
Could we get confirmation for that from @Larry. I remember $Larry
mentioning that Num fails over to Rat or so when necessary. IOW,
does
my Rat $rat = 1/3; # assuming infix:</> returns a Rat
my Num $num = 1/3;
my Rat $diff = abs($rat - $num);
store a non-zero value in $diff? I assume that Num is discrete with a
binary representation and infix:<->:(Rat,Num-­->Rat) converts $num to a
fraction with a power of two in the denominator. BTW, with floor
semantics I would expect $num < $rat.


I've not seen any detailed design for how those types interact.
Whichever direction is the "promotion", the two values are unequal.


Add comment
John M. Dlugosz 8 August 2008 11:55:47 permanent link ]
 TSa Thomas.Sandlass-at-­barco.com |Perl 6| wrote:
HaloO,
mark.a.biggar@comca­st.net wrote:
Let's just make sure we're handling inf and -inf right and leave all
that other stuff until later.
The point is: what is the minimum we need to be future proof
and compatible to other language features.
Regards, TSa.

So why don't you try designing a module that provides one of these other
models, and see if it runs into trouble stepping on the proposed
built-ins or runs into problems being upward compatible with the basic.

--John
Add comment
Mark J. Reed 8 August 2008 17:08:14 permanent link ]
 On Thu, Aug 7, 2008 at 11:31 AM, Will Coleda <will@coleda.com> wrote:
On Thu, Aug 7, 2008 at 11:29 AM, <mark.a.biggar@comc­ast.net> wrote:
Supporting multiple levels of infinities, transfinite numbers or even Surreal Numbers should be considered in the same category of features as returning multiple answers from complex trig functions.
They're an interesting thing to discuss and experiment with but shouldn't distract form getting Perl 6 out the door. Let's just make sure we're handling inf and -inf right and leave all that other stuff until later.
+1

Agreed. Let's not fall into the trap of thinking that because a
general-purpose programming language necessarily does arithmetic, it
is also a domain-specific language for mathematics. I agree that we
should try not to make it too hard to layer such language into Perl6,
but I see no point in bending over backwards to make it particularly
easy compared to other domain-specific languages...

--
Mark J. Reed <markjreed@gmail.co­m>
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > Perl web-programming > new article, "A Romp Through Infinity" 8 August 2008 17:08:14

see also:
newbie problem working with Forms…
Posting VARS in PHP 4.x
mkdir question
пройди тесты:
see also:
The valley of life
My Best Person
My heart.....

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .