[Purdue-pm] Perl 6

Mark Daniel Ward mdw at purdue.edu
Tue Jul 10 06:52:07 PDT 2018

```Dear Mark,

Perl 6 can do this so quickly, because it knows the formula you
mentioned (which was also known to Gauss, and is known to all math
students now).

I wonder what repository of formulas like this are known by Perl, and
how it learns new formulas.

This seems to be a key strength of Sage (which is built on Python),
which is causing Sage to take over the symbolic math world (formerly a
territory that Maple and Mathematica owned). Sage is community
developed, so anybody can make contributions to similar formulas that
Sage would inherently know.

This is a key strength of Sage over Mathematica, and I wonder if it is a
strength of Sage over Perl 6 ?  For comparison, do you know how to
enable Perl to learn other formulas that might be found in the OEIS
(On-Line Encyclopedia of Integer Sequences) that have nice formulas?

Mark

On 7/10/18 8:56 AM, Mark Senn wrote:
> Carl Friedrich Gauss added the integers from 1 to 100 ca 1784
> using the formula (n/2)(n+1).  See pages 12--13 of
> for details.
>
>
> Brian Duggan <bduggan2 at gmail.com> wrote on 2018-07-10 at 06:42 -04:
> To: ToddAndMargo <ToddAndMargo at zoho.com>
> Cc: perl6-users <perl6-users at perl.org>
> Subject: Re: An interesting math formula to share
> Message-ID: <20180710104250.GA22895 at localhost>
> |  Another cool thing is that this formula is used in Perl 6 under the hood
> |  to calculate the sum of the integers in a range instantly:
>
>
> It nice not to worry about integer overflow with Perl 6.
> Perl 6 has the formula to add integers from 1 to n built-in
> so adding 1 to 10^1000 doesn't take much longer than adding
> 1 + 2 + 3.
>
> \$ /usr/bin/time -f '%e wall clock seconds' perl6 -e 'say [+] 1..3'
> 6
> 0.39 wall clock seconds
>
> \$ /usr/bin/time -f '%e wall clock seconds' perl6 -e 'say [+] 1..10'
> 55
> 0.40 wall clock seconds
>
> \$ /usr/bin/time -f '%e wall clock seconds' perl6 -e 'say [+] 1..10**1'
> 55
> 0.40 wall clock seconds
>
> \$ /usr/bin/time -f '%e wall clock seconds' perl6 -e 'say [+] 1..100'
> 5050
> 0.40 wall clock seconds
>
> \$ /usr/bin/time -f '%e wall clock seconds' perl6 -e 'say [+] 1..10**2'
> 5050
> 0.40 wall clock seconds
>
> \$ /usr/bin/time -f '%e wall clock seconds' perl6 -e 'say [+] 1..10**1000'
> 50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
>   0050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
>   00000
> 0.41 wall clock seconds
>
>
> -mark
> _______________________________________________
> Purdue-pm mailing list
> Purdue-pm at pm.org
> http://mail.pm.org/mailman/listinfo/purdue-pm
```