Finding the aproximate integer Sqrt of a large prime

In summary, the conversation discusses finding the square root of a large prime number in integer form and the difficulties the person is facing with their current method. Another person suggests using a different algorithm that involves using (x+k)^2 = x^2 + 2kx + k^2 and adjusting the values of x and k until the result is equal to the prime number. They also mention a method for calculating the decimal digits of the answer. The person is thankful for the suggestion and clarifies a question about the algorithm.
  • #1
Facet
2
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
  • #2
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.
 
  • #3
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 =)
 

Related to Finding the aproximate integer Sqrt of a large prime

1. How do you find the approximate integer square root of a large prime number?

The approximate integer square root of a large prime number can be found using the square root function in a programming language or by using a mathematical algorithm such as the Newton's method or the Babylonian method.

2. Why is it important to find the approximate integer square root of a large prime number?

It is important to find the approximate integer square root of a large prime number because it can help in various mathematical calculations and in finding factors of the prime number.

3. Can the approximate integer square root of a large prime number be calculated without using a computer?

Yes, the approximate integer square root of a large prime number can be calculated manually using mathematical algorithms such as the Newton's method or the Babylonian method.

4. Is the approximate integer square root of a large prime number always an exact value?

No, the approximate integer square root of a large prime number is not always an exact value. It is an approximation and may have a small margin of error.

5. Are there any limitations to finding the approximate integer square root of a large prime number?

Yes, there are limitations to finding the approximate integer square root of a large prime number. The accuracy of the approximation depends on the algorithm used and the size of the prime number.

Similar threads

Replies
1
Views
2K
  • General Math
Replies
1
Views
1K
Replies
1
Views
760
  • Set Theory, Logic, Probability, Statistics
Replies
3
Views
777
Replies
9
Views
2K
  • Precalculus Mathematics Homework Help
Replies
12
Views
1K
  • Programming and Computer Science
Replies
14
Views
2K
  • Calculus and Beyond Homework Help
Replies
3
Views
762
  • Engineering and Comp Sci Homework Help
Replies
32
Views
3K
Replies
4
Views
478
Back
Top