Finding the aproximate integer Sqrt of a large prime

  • Context: Graduate 
  • Thread starter Thread starter Facet
  • Start date Start date
  • Tags Tags
    Integer Prime
Click For Summary
SUMMARY

This discussion focuses on efficiently calculating the integer square root of large prime numbers, specifically those exceeding 3000 digits, such as the example of 188 multiplied by 3 to the power of 6548 plus 1. The user initially attempted a division through subtraction method and the Babylonian method (x+a/x)/2, both of which proved inefficient. A proposed solution involves using the formula (x+k)^2 = x^2 + 2kx + k^2, starting with x as the largest power of 2 less than the prime and iteratively adjusting k until convergence. This method significantly improves computational speed for large prime square root calculations.

PREREQUISITES
  • Understanding of prime numbers and their properties
  • Familiarity with integer arithmetic and large number computations
  • Knowledge of the Babylonian method for square roots
  • Basic algebra, particularly manipulation of equations
NEXT STEPS
  • Research efficient algorithms for large integer arithmetic
  • Learn about the properties of prime numbers and their applications
  • Explore advanced numerical methods for square root calculations
  • Investigate the use of binary versus decimal arithmetic in large computations
USEFUL FOR

Mathematicians, computer scientists, and software developers working with cryptography or large number theory who need to optimize calculations involving large primes.

Facet
Messages
2
Reaction score
0
I am trying to understand how I can find the square root of a large prime number in the form of an integer value, the portion after the decimal is irelevant.

The numbers I wish to compute range around 188 multiplied by 3 to the power of 6548 plus 1, as an example. so let's say in excess of 3000 digits.

My problem with this is, using my quad-core machine, I'm finding my petty division through subtraction routine fairly slow, and (x+a/x)/2 as a solution is failing badly.

Can someone please find time to discuss with me a way of doing this?

Can a prime have a GCD with a smaller number(like the sqrt), I somehow just don't see it...

So if there is an easy solution, please let me know it =)
 
Mathematics news on Phys.org
You don't need to do any division at all.

Just use (x+k)^2 = x^2 + 2kx + k^2

Call your prime p. Start with x = the largest value of [itex]2^m[/itex] where [itex]x^2 < p[/itex], and [itex]k = x/2[/itex]

Find (x+k)^2. If it is less than p, let x = x+k.
Divide k by 2 and repeat, until k = 1.

If your big arithmetic routines work in decimal not binary, you can use the same sort of algorithm to pick off one decimal digit of the answer at a time.

You don't need to spend time calculatiing the right-hand digits of the numbers that you know are zero, of course.
 
Thankyou for the quick reply, much appreciated... =)
I really need to touch up on my maths =(
I'm sure what you posted will help me out...
I can straight away see how much faster that would be ;)
one quick question - what is m
Edit: nvm - I think I see what you say =)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
7
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
Replies
14
Views
3K
  • · Replies 1 ·
Replies
1
Views
30K
  • · Replies 1 ·
Replies
1
Views
2K