Is dealing with large numbers as formula a thing? and how is it done?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 2K views
AtlasSniperma
Messages
22
Reaction score
0
TL;DR
Arithmetic using numbers in equation form?
Hi everyone.
I haven't been here in years, I'm surprised the account still works.

Anyway. I have a mathematic thought/question that I really want to learn about. I realize this isn't going to be the easiest thing to explain if it is even possible, so please forgive me.

So, What I want to do is be able to extract a specific digit from a number when that number is stored in some formulaic form.

An easy example: 111^2, digit 1(leftmost, 10,000s column, whatever) = 1. digit 3 = 3, digit 4 = 2 etc.

A more understandable example is the number 2^(82589933) - 1 which is one of the largest known primes.
My computer will never be able to process that number as a standard number, so I'd love to be able to do arithmetic on it while it's in this more easily maneuvered form.

ultimately, in this case, I'd love to be able to incorporate this methodology into an iterative function that prints the number one digit at a time so as to not attempt to choke on it's sizeable girth.

I do remember hearing about something like this being used with Pi, but I do realize that's not necessarily related to the field I'm asking about.I hope that makes sense. Thanks for any advice anyone can give.
 
Mathematics news on Phys.org
Actually 2^(82589933) - 1 isn't all that big. It will fit in about 10 Megabytes. Adding 2 numbers of that size will be about a millisecond. Multiplying two numbers of that size would take a computer about an hour using the elementary school method, that uses a number of operations that is proportional to the square of the input size, but can still be done in under a second by using a fast Fourier transform method.
 
There is no single general method that will always work.

What often works for the last digits is modular arithmetic. If you just care about the last digit, only calculate the remainder when divided by 10, if you are interested in the last two take the remainder mod 100 and so on. As an example for powers of 2 (subtracting 1 is trivial):
20 = 1
21 = 2
22 = 4
23 = 8 = 8 (mod 10)
24 = 16 = 6 (mod 10)
25 = 32 = 2 (mod 10)
26 = 64 = 4 (mod 10)
from here on it is always the cycle 2,4,8,6, ... That means we can subtract a multiple of 4 from the exponent without changing the last digit.

282589933 = 282589932+1 = 21 = 2 mod 10
Therefore 282589933-1 ends in a 1.

I didn't use a calculator anywhere. With a bit more work you can get the next to last digit as well, and a computer will quickly produce the last 10 digits that way.

Approximations can work for the first digits. ##\log(2^{82589933}) = 82589933 \log(2) \approx 24862047.17288##. Therefore ##2^{82589933} \approx 10^{24862047+0.17288} = 10^{0.17288} \cdot 10^{24862047} = 1.4889 \cdot 10^{24862047}##. And indeed, the prime starts with 14889 and has 24862048 decimal digits.