Hi,
Consider Euler’s famous expression x=a^2+n*b^2. I want to solve a and
b, given x and n. Because solve_mod is totally broken, I tried to
develop a clever method myself. Counterintuitively, I found that the
most simple brute force method in SAGE is relatively fast.
def bruteforce(number,n):
out=[]
for b in xrange(isqrt(number/n)):
(bool,a)=is_square(number-n*b^2,True)
if bool: out.append((a,b))
return out
My questions are:
- Why is the brute force method relatively fast?
- Is there a clever approach (not dependent on solve_mod)?
Thanks in advance! Roland
--
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org