# Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

# Overflow?

#### vefatica

What causes "overflow", as below, and can I anticipate it?

g:\projects\4utils\release> echo %@sterling[3249] | wc
Lines Words Chars
1 1 10003

g:\projects\4utils\release> echo %@sterling[3250] | wc
TCC: Overflow "(2 * acos(-1) * 3250) ** (1 / 2) * (3250 / exp(1)) ** 3250"
Lines Words Chars
1 15 60

Note: Sterling's formula, seen above in the error message, approximates
N-factorial. The result for N=3250 would have been 3-4 characters longer than
the result for 3249 (or about 10007 characters). Apparently I have run into
some limit I'm not aware of.

vefatica wrote:

> What causes "overflow", as below, and can I anticipate it?
>
> g:\projects\4utils\release> echo %@sterling[3249] | wc
> Lines Words Chars
> 1 1 10003
>
> g:\projects\4utils\release> echo %@sterling[3250] | wc
> TCC: Overflow "(2 * acos(-1) * 3250) ** (1 / 2) * (3250 / exp(1)) ** 3250"
> Lines Words Chars
> 1 15 60
>
> Note: Sterling's formula, seen above in the error message, approximates
> N-factorial. The result for N=3250 would have been 3-4 characters longer
> than
> the result for 3249 (or about 10007 characters). Apparently I have run into
> some limit I'm not aware of.

An Overflow error will occur if the digits to the left of the decimal
exceed 10,000 characters.

Rex Conn
JP Software

From: rconn
Sent: Friday, June 13, 2008 1:40 PM
Subject: RE: [Support-t-192] Overflow?

>
> An Overflow error will occur if the digits to the left of the decimal
> exceed 10,000 characters.

Rex,

Can you work with Wolfram Systems for V10 and integrate Mathematica into the
TCC code base? The increased startup time would be more than compensated-for
by the improvement in expression processing. ;-)

I jest,

Jonathan Gilbert_
\\\ / / / \ |_) |_/
\\\/ \/ \__/ | \ | \
Software Systems

vefatica wrote:
| Note: Sterling's formula, seen above in the error message,
| approximates N-factorial.

That's "Stirling's formula"...
--
Steve

On Fri, 13 Jun 2008 15:42:37 -0500, you wrote:

>That's "Stirling's formula"...

It's the one I know:

n! ~ sqrt(2*pi*n)(n/e)^n

Maybe he has others. He has a bunch of numbers too.

Oh!, now I get it. Indeed, it's Stirling's formula.

logic wrote:

> Quote:
> >
> > An Overflow error will occur if the digits to the left of the decimal
> > exceed 10,000 characters.
>
> Rex,
>
> Can you work with Wolfram Systems for V10 and integrate Mathematica into the
> TCC code base? The increased startup time would be more than compensated-for
> by the improvement in expression processing. ;-)

I've had people nagging me for years for > 80 bit precision in @EVAL. I
thought that 20,000 digit precision (10k to the left & 10k to the right
of the decimal) ought to be sufficient to satisfy even the fussiest
user; I should have known better.

Though exactly *why* anybody needs numbers larger than the number of
subatomic particles in the universe is still a mystery to me ...

Rex Conn
JP Software

Though exactly *why* anybody needs numbers larger than the number of
subatomic particles in the universe is still a mystery to me ...

Permutations and combinations of the number of subatomic particles in the universe?

Charles Dye wrote:

>
> Quote:
> Originally Posted by *rconn* View Post <showthread.php?p=801#post801>
> Though exactly *why* anybody needs numbers larger than the number of
> subatomic particles in the universe is still a mystery to me ...
>
> Permutations and combinations of the number of subatomic particles in
> the universe?

Nope, still got that covered. 10^10000 is a REALLY big number ...

Rex Conn
JP Software

Charles Dye wrote:
| ---Quote (Originally by rconn)---
| Though exactly *why* anybody needs numbers larger than the number of
| subatomic particles in the universe is still a mystery to me ...
| ---End Quote---
| Permutations and combinations of the number of subatomic particles in
| the universe?

National debt?
--
Steve

From: rconn
Sent: Monday, June 16, 2008 9:58 AM
Subject: RE: [Support-t-192] Re: Overflow?

> > Permutations and combinations of the number of subatomic particles in
> > the universe?
>
> Nope, still got that covered. 10^10000 is a REALLY big number ...

Actually I don't think you have got it covered. A conservative estimate of
the number of particles in the universe is 10^80. To count all of the
possible permutations of all of the subatomic particles in the universe, you
need to be able to store (10^80)! numerically. This is a REALLY, REALLY,
REALLY big number!

Stirling's approximation:

N! ~= sqrt(2 pi N) * (N/e)^N

N in this case is 10^80 -- 1 followed by 80 zeroes. Putting this into the
formula yields:

sqrt(2 pi 10^80) * (10^80 / e) ^ 10^80

The first factor breaks down to sqrt(2 pi) * sqrt(10^80), which is 10^40 *
sqrt(2 pi). The second factor takes a number marginally under 10^80 and puts
it to the power of 10^80. The exact base being exponentiated can be
determined as follows:

ln(10^80 / e)
10^80 / e = e
(ln(10^80) - ln(e))
= e
(184.2068 - 1)
= e
183.2068
= e
183.2068 / ln(10)
= 10
79.5657
= 10

This leaves us with:

_ _ 10^80
| 79.5657 | (79.5657 * 10^80)
| 10 | = 10
|_ _|
7.95657 * 10^81
= 10

This number is slightly less than 1 followed by (10^81 + 8) zeroes. There is
no way you could store this in a variable with room for 1 followed by 10,000
zeroes. 10^81 is significantly larger than 10^4. :-)

Jonathan Gilbert_
\\\ / / / \ |_) |_/
\\\/ \/ \__/ | \ | \
Software Systems

From: logic
Sent: Monday, June 16, 2008 10:27 AM
Subject: RE: [Support-t-192] Re: Overflow?

>
> > > Permutations and combinations of the number of subatomic
> > > particles in the universe?
> >
> > Nope, still got that covered. 10^10000 is a REALLY big number ...
> The first factor breaks down to sqrt(2 pi) * sqrt(10^80), which is
> 10^40 * sqrt(2 pi). The second factor takes a number marginally under
> 10^80 and puts it to the power of 10^80. The exact base being
> exponentiated can be determined as follows:
[snip]

> This leaves us with:
>
> _ _ 10^80
> | 79.5657 | (79.5657 * 10^80)
> | 10 | = 10
> |_ _|
> 7.95657 * 10^81
> = 10
>
> This number is slightly less than 1 followed by (10^81 + 8) zeroes.

Oh, and of course I forgot to include the first factor. In fact we're
looking at

40 7.95657 * 10^81
sqrt(2 pi) * 10 * 10

Not that adding an additional 40 zeroes makes much difference when you
already have 10^81 zeroes. Not 81 zeroes, but 10^81 zeroes.

It is a number so large that the human brain struggles to comprehend it. It
is the same league as taking a googol and putting it to the power of a
googol.

Jonathan Gilbert_
\\\ / / / \ |_) |_/
\\\/ \/ \__/ | \ | \
Software Systems

Not that adding an additional 40 zeroes makes much difference when you
already have 10^81 zeroes. Not 81 zeroes, but 10^81 zeroes.

It is a number so large that the human brain struggles to comprehend it. It
is the same league as taking a googol and putting it to the power of a
googol.

Yes, that is a very big number, but why would any one want to work with numbers like that in a command processor or shell?

Use Mathematica, eh?

- Josh

On Mon 16-Jun-08 10:27am -0600, logic wrote:

>On Monday, June 16, 2008 9:58 AM, rconn wrote:

>>> Permutations and combinations of the number of subatomic particles in
>>> the universe?

>> Nope, still got that covered. 10^10000 is a REALLY big number ...

> Actually I don't think you have got it covered. A conservative estimate of
> the number of particles in the universe is 10^80. To count all of the
> possible permutations of all of the subatomic particles in the universe, you
> need to be able to store (10^80)! numerically. This is a REALLY, REALLY,
> REALLY big number!

I don't remember where I got this, but my functions include
lfac (which computes log(x!) -- the natural log). Given
that, solving the problem is simple. There are six lines
below - some of them may spill over in your email programs:

[Caution: this will not work in 4nt - use tcc.]

function lfac=`%@eval[%1*log(%1)-%1+log(%1*(1+4*%1*(1+2*%1)))/6+.5723649429247001]`
set x=%@eval[%@lfac[10**80]/log(10)]
set y=%@eval[%x-.5=0.0]
set z=%@eval[10**(%x-%y)=0.4]
echo %z * 10 ** %y
unset x y z

You should see the approximate answer as:

3.5476 * 10 ** 7956570551809674817234887108108339491770560299419633343388554621683413535079112945

That is 3.5476 times 10 to the N, where N is a 82 digit
integer.

--
Best regards,
Bill

Yes, that is a very big number, but why would any one want to work with numbers like that in a command processor or shell?

I think that the message is very clear here: somewhere outside of and beyond our universe is an operating system, coded up over incalculable spans of time by some kind of hacker-demiurge. The cosmic operating system uses a command-line interface. It runs on something like a teletype, with lots of noise and heat; punched-out bits flutter down into its hopper like drifting stars. The demiurge sits at his teletype, pounding out one command line after another, specifying the values of fundamental constants of physics:

universe -G 6.672e-11 -e 1.602e-19 -h 6.626e-34 -protonmass 1.673e-27....

and when he's finished typing out the command line, his right pinky hesitates above the ENTER key for an aeon or two, wondering what's going to happen; then down it comes--and the WHACK you hear is another Big Bang.

-- Neal Stephenson, In the Beginning Was the Command Line

On Tue, Jun 17, 2008 at 11:27 AM, Charles Dye <> wrote:

> and when he's finished typing out the command line, his right pinky hesitates above the
> ENTER key for an aeon or two, wondering what's going to happen; then down it
> comes--and the WHACK you hear is another Big Bang.

Boot Universe. No sync.

> Charles Dye
______
Dennis