Solve linear system with equivalent constraints #22848
Replies: 2 comments 3 replies
-
Using a debugger I found that it was stuck in |
Beta Was this translation helpful? Give feedback.
-
The slow part is this: In [39]: p
Out[39]:
Poly(x**32 - 23776*x**30 + 262391808*x**28 - 1783989246208*x**26 + 8362639002995968*x**24 - 2865472
5868686256128*x**22 + 74231442547565626228736*x**20 - 148277759076406070066069504*x**18 + 230765119
607918170280528928768*x**16 - 280689131263236369909031730020352*x**14 + 265888219837056222602262617
935314944*x**12 - 194039855941981642000534897817017122816*x**10 + 106917503395998066171929481558359
532371968*x**8 - 42986723995932738985820456209469302651224064*x**6 + 118889682596721226221205393175
07366039010148352*x**4 - 2020117826497308403039977029311872564169258565632*x**2 + 15879475998564743
2069803491574881826802397259759616, x, domain='QQ<sqrt(4290)>')
In [40]: %time p.factor_list()
... That's being called inside primitive_element([sqrt(10), sqrt(11), sqrt(1430), sqrt(2), sqrt(33), sqrt(4290), sqrt(6)], ex=True, polys=True) This is because I have wondered for a while now whether it would be possible to make a more efficient way of representing simple algebraic number fields that only involve surds. Rather than making a primitive element it should be possible to represent elements of the field using sparse polynomials in the surds of the basic prime numbers. Constructing a primitive element gets slow very quickly and the representations of the basic generating elements get more and more complicated as you increase the number of surds: In [51]: %time ok = primitive_element([sqrt(2), sqrt(3)], ex=True)
CPU times: user 36 ms, sys: 0 ns, total: 36 ms
Wall time: 35 ms
In [52]: %time ok = primitive_element([sqrt(2), sqrt(3), sqrt(5)], ex=True)
CPU times: user 48 ms, sys: 0 ns, total: 48 ms
Wall time: 48.2 ms
In [53]: %time ok = primitive_element([sqrt(2), sqrt(3), sqrt(5), sqrt(7)], ex=True)
CPU times: user 124 ms, sys: 0 ns, total: 124 ms
Wall time: 123 ms
In [54]: %time ok = primitive_element([sqrt(2), sqrt(3), sqrt(5), sqrt(7), sqrt(11)], ex=True)
CPU times: user 724 ms, sys: 0 ns, total: 724 ms
Wall time: 724 ms
In [55]: %time ok = primitive_element([sqrt(2), sqrt(3), sqrt(5), sqrt(7), sqrt(11), sqrt(13)], ex=Tr
...: ue)
^C---------------------------------------------------------------------------
KeyboardInterrupt |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have
sympy 1.9
installed and I try to solve the following system of linear equations:Some lines in this system are equivalent. For instance if I solve the 10 first line I get the correct solution in less than 3 seconds:
Here is my problem, if I try to solve the full system with
sympy.solve(constraints, variables)
the algorithm is still running after few minutes of executions.Using the git version
1.10.dev
does not solve the problem.Beta Was this translation helpful? Give feedback.
All reactions