Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

On a computer I can have integers on arbitrary size thanks to GMP, so it's represented in base 2 in memory.

I'm wondering if it's possible in theory to use less memory if I store only prime factors and their exponent, I think it's worthless for most numbers, but I wonder if it works for a very small minority of numbers with large prime factors.

How can I prove me wrong ?

share|improve this question
2  
I think for some numbers this would definitely use less memory to store them that way. But finding this factorization is costly, and you would need to revert to the usual representation to perform a sum. –  Joel Cohen Oct 12 '12 at 0:02
    
@Joel, for some certainly, but not at all on average. –  Dan Brumleve Nov 17 '12 at 13:01

2 Answers 2

No, it is not possible. In general, there is no algorithm that compresses every $n$ bit string, or reduces the length of a random string of bits (in expectation).

Your algorithm may compress some numbers but then it will use more memory to store others. If your data is random, there is no benefit in using your compression scheme.

Actually the fact that no such compression scheme exists can be used to prove that there are infinitely many prime numbers — otherwise, if there were only finitely many prime numbers your compression scheme would be very efficient!

There are excellent lecture notes on Kolmogorov Complexity by Alexander Shen that discuss “incompressability”; in particular, Shen writes about your compression algorithm in Section 18.

share|improve this answer
1  
"Actually the fact that no such compression scheme exists can be used to prove that there are infinitely many prime numbers — otherwise, if there were only finitely many prime numbers your compression scheme would be very efficient!" That is fantastic. –  crf Nov 15 '12 at 6:51
    
Regarding: "Actually the fact that no such compression scheme exists can be used to prove that there are infinitely many prime numbers — otherwise, if there were only finitely many prime numbers your compression scheme would be very efficient!" That is fantastic. Response by hodonkain: That's why it's done in chunks. So the prime number will always have a maximum. –  user49504 Nov 15 '12 at 10:22
    
This answer is okay but I think there is a more subtle and interesting aspect to the question when we consider the error bound. –  Dan Brumleve Nov 17 '12 at 12:59

Something which sort of implies that the answer might be yes in some circumstances (I specialize in precision!) is that solving linear equations with large integer coefficients can be done by solving the system modulo a number of primes (or relatively prime values such as $2^n-1$ for appropriate $n$) and combining the results using the Chinese remainder theorem. You have to have enough moduli so the their product is larger than any of the results.

share|improve this answer
    
Surely in some circumstances but else what? –  Dan Brumleve Nov 17 '12 at 13:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.