Thanks to both of you for the recommendations. I will follow them.

 

Tom

(Dr. Thomas S. Ligon)

 <mailto:thomassli...@gmail.com> thomassli...@gmail.com

Frohnloher Str. 6a
81475 Muenchen
Germany
Tel. +49(89)74575075

 

From: sympy@googlegroups.com <sympy@googlegroups.com> On Behalf Of Aaron Meurer
Sent: Sunday, August 7, 2022 7:42 AM
To: sympy@googlegroups.com
Subject: Re: [sympy] storing big integers as prime factors

 

As Oscar pointed out, it's not clear that this would actually be more 
efficient. However, some things that could help, based on what you've said, are

 

- Use Poly and any relevant Poly methods to represent and manipulate polynomial 
expressions

- Make sure gmpy2 is installed. If it is, SymPy will automatically use it for 
much faster integer operations, especially when using Poly.

- Rewrite your recursive function to operate non-recursively. Recursive 
functions are slower in Python than normal loops. 

 

Aaron Meurer

 

On Sat, Aug 6, 2022 at 8:08 AM Thomas Ligon <thomassli...@gmail.com 
<mailto:thomassli...@gmail.com> > wrote:

Is there any way to do this, perhaps just by saying that I want to keep prime 
factors instead of decimal digits?

Background: I am writing software (using Python and SymPy) to calculate the 
coefficients of a power series. By using Rational(0) to initialize sums and 
Rational(1,2) to avoid getting a floating point, I have results that are always 
rational, specifically quotients of large integers and have reached the point 
where the integers have about 50 digits. I have a (fairly complex) recursive 
function that calculates the coefficient of x**(n+1) when the coefficients of 
x**n are known. When calculating the sum of two rational numbers, this most 
likely calculates the greatest common denominator, something which is sure to 
be hard. If all of the integers were always stored in terms of their prime 
factors instead of decimal digits, it would be much more efficient.

Is there such a feature out there somewhere?

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com 
<mailto:sympy+unsubscr...@googlegroups.com> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/7171be2f-67a7-4d48-8eac-5d37571677c4n%40googlegroups.com
 
<https://groups.google.com/d/msgid/sympy/7171be2f-67a7-4d48-8eac-5d37571677c4n%40googlegroups.com?utm_medium=email&utm_source=footer>
 .

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com 
<mailto:sympy+unsubscr...@googlegroups.com> .
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAKgW%3D6K30P76B8J%2B4rBrqQ0bCzV0OHY%3DJjZjaKb4ZkWzRZUYoA%40mail.gmail.com
 
<https://groups.google.com/d/msgid/sympy/CAKgW%3D6K30P76B8J%2B4rBrqQ0bCzV0OHY%3DJjZjaKb4ZkWzRZUYoA%40mail.gmail.com?utm_medium=email&utm_source=footer>
 .

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/005d01d8aa33%240800e500%241802af00%24%40gmail.com.

Reply via email to