You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
Hi,
I used in some experiments the following simple code.
import time
from sympy.solvers import solve
from sympy import Symbol
x=Symbol('x')
N=2**264+2**64+1
solve(x**2 + N , x)
The previous code is very slow (at least in my machine, in fact I didn't wait to see the result). I want to ask if solve() command, before it prints the result tries to compute some factors of N, in order to simplify the result in the square root?
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sympy
Hi Costas,
Indeed, solve() is too slow. You can get around it with:
In [12]: solve(x**2 + y, x)
Out[12]:
⎡ ____ ____⎤
⎣-╲╱ -y , ╲╱ -y ⎦
In [15]: _12[0].subs(y, N)
Out[15]:
-33⋅√2722017892080160333189547489644086722721498262112395261166314045249755270
6497⋅ⅈ
This is immediate and should give you the right results.
Ondrej
Aaron Meurer
unread,
May 28, 2015, 4:25:25 PM5/28/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
It looks like solve is calling factorint at some point. sqrt(N) will
already simplify intelligently (i.e., call factorint() with the limit
argument so that it isn't too slow). It looks like somewhere in
polyroots it is trying to compute all the divisors of the number. We
should investigate why it is doing this. I can see why that might be
necessary to compute the roots of a polynomial in general, but it
shouldn't be done when computing the roots of a quadratic.