How do I calculate really big numbers?

Say I want to find the result of this calculation:

17,000,000^800,000

(that is, seventeen million to the eight hundred-thousanth power).

Is it possible for me to calculate this on my home PC? If not, why not? If so, what programs can I use to do so?

How many digits would that be?

You need something like this.

Here’s another big number calculator. It’s a perl script by Robert Munafo, whose work I have cited in other GQ threads on numbers.

DarrenS: Nope. That program errors out with “Exponent too big.” So much for being able to handle any calculation:)

Why do you need to calculate such a big number?

Well, I can tell you that there’d be about 59 million digits in the product mentioned (a ballpark guess) if that’s any help. That’s a few books’ worth of numbers.

Let me know if you publish: I collect first editions…

log(17000000[sup]800000[/sup])
= 800000 log(17000000)
= 57843591.371026

17000000[sup]800000[/sup]
= 10[sup]57843591.371026[/sup]
= 10[sup]0.371026[/sup]×10[sup]57843591[/sup]
= 2.34977×10[sup]57843591[/sup]

which has 57843952 digits. You can get more precision by computing the logarithm to higher precision.

How much accuracy do you need? You can get maybe parts per million accuracy on a good scientific pocket calculators using logs to reduce the decimal places and keep your digits from overflowing. A high precision calculator program might be able to give you ca. 19 digits precision per 64 bits of calculator precision.

I could cheat and plug it into mathlab or mathematica, but where’s the fun? Here’s what I get using a paperback log table and a pencil:

17,000,000^800,000 = (1.7*10^7)^800,000
log 1.7 = 0.2304489214

Therefore
17,000,000^800,000
= 10^ ([7+ 0.2304489214]*800.000)
≈ 10^(5,600,000 + 184359.13712)
≈ 10^(5,784,359 + 0.13712)
≈ 1.371260607 x 10^5,784,359

Interestingly, your number approximates the solution of x=10log(x) with the decimal point moved 5,784,359 places to the right
Might that have something to do with your interest in this number?

oops. I see achenar beat me too it. I lost half an hour after I started trying to find a paperback log table

Actually, I remove my oops. It appears achenar slipped a digit in his calculations.

Woo-hoo!

I did an off-the-cuff WAG and got within a couple of percent of the real answer.

Who wants to hire me?

You’re right. I accidentally punched 8,000,000 into my calculator instead of 800,000. Sorry to get your hopes up MonkeyMensch. :wink:

You guessed 5,784,359 and the exponent on a WAG? I AM impressed! Of course if you were even one number off there, you were way off.

Coming within a few percent on a WAG is easier than it seems. Since the leading digit of the root is 1, most people would guess the leading digit of the mantissa would be 1 - but with an exponent as high as 800,000, this would usually end up being completely wrong. It just so happens that in this case, the first digit of the mantissa ended up being 1 anyway. if the exponent had instead been 500,000 -or 800,001- the first digit of the mantissa would’ve been 2

oops, that should be:
“You guessed 5,784,359 as the exponent on a WAG?”

Note that if you’re exponentiating exactly 17 million then most of the digits in your answer will be zeroes:
17,000,000[sup]800,000[/sup] = 17[sup]800,000[/sup] 10[sup]4,800,000[/sup]: that is, 17[sup]800,000[/sup] followed by 4,800,000 zeroes. The Unix calculator bc can compute 17[sup]800,000[/sup] in about a minute on my machine; the answer takes up 14476 lines of output. Add zeroes to taste.

Actually, the real number I wanted is the result of 16777216^786432. The reason I want this number is because I wanted to write a program to output an image based on a number. That number above would represent all the possible image combinations of a 1024x768 image with 16.7 million colors. (The theory being that you can create a fairly decent resolution image of everything and everyone ever born, or to be born.)

I realize that it’s a really large number, but it’s just a casual program I have rolling around in my head. I wouldn’t want to create each individual image (as that would take a REALLY long time), I would just want to be able to select (or randomly pick) a number and have it created using some yet-to-be-created-by-me algorithm.

So, I would need to be able to calculate and work with that really big number, unless I could fake it somehow…but I’m a purist. :slight_smile: Is it possible for our current machines to use that number as a single variable? How many bits would that take up?

I realize I could ask in a mathematics or technical forum… but I’m a humanities (philosophy) major, not a science major :wink:

(As an aside, I’ve created a little perl script that will generate a page of text using letters and basic punctuation… run it enough times and you would have everything that could possibly be written in the English language… of course, reading through it all would be a real pain.

calc, a C-like interactive programming language with arbitrary-precision arithemetic. – It masquerades as a bc-like calculator, but the programmability has taken a much more central role. The syntax is more mature, for instance, and the features are more flexible. calc is, in my opinion, a good choice for writing real programs that need real big numbers. :slight_smile:

You do realise you’ll have to type in a 6 million digit number to get your picture, don’t you?

It’d be quicker to just randomly color pixels in MS-Paint.

Save the result as a .BMP file, and the .BMP file itself (minus the header and other housekeeping stuff) is your number.

Or in reverse order, create a blank .BMP file using Paint. Edit the .BMP file directly, and there’s your new number and your new picture.

Of course, if you really insist on doing it the hard way, and entering all 6 million digits into a file, all your program needs to do is to convert that ASCII decimal representation into binary in some fashion, and output the result to a .BMP file.

It’d probably take a skilled programmer a few minutes to write.

This one is easy. It’s exactly the same number of bits that your video memory takes up - 1024 × 768 × 24 = 18,874,368. 2.25 megabytes.

If you want to see it mathematically, it’s like this:

log[sub]2/sub
= 786432 log[sub]2/sub
= 786432 log[sub]2/sub
= 786432 × 24 = 18,874,368