On Tue, Feb 16, 2016 at 12:39 PM, Aaron Meurer <[email protected]> wrote:
> The problem here isn't so much to do with trig identities as the big
> numbers. The issue is that things like
> factorial(847937526693730893984732849857349) and
> 1342**(87236487262873**(8732498237693269832+3)+5)-1) evaluate
> automatically, which causes Python to try to compute them until the
> memory fills up and it crashes.
>
> The way I would fix this is to create a special BigInteger object,
> which would wrap large integers and avoid explicit computation. For
> example, BigInteger(10)**BigInteger(10)**BigInteger(100) would remain
> unevaluated. It would then use some algorithms and the assumptions
> system to compute facts. So something like
> factorial(BigInteger(847937526693730893984732849857349)).is_integer
> would be True, which would be enough for
> sin(pi*factorial(BigInteger(847937526693730893984732849857349))) to
> simplify.  There are some cool things that you could do with this,
> like (2**BigInteger(74207281) - 1).is_prime. For anyone interested,
> there's probably enough cool stuff that could be done here for a GSoC
> project.
>
> (By the way, I had an issue open in the issue tracker a while ago
> about this, but I can't find it)

Another point is that SymPy should not do automatic simplification of
these large things, because the code to do that is not completely
trivial and always fast. However, there should be a function in sympy
that can do these simplifications when called explicitly by the user.

Ondrej

>
> Aaron Meurer
>
> On Tue, Feb 16, 2016 at 2:02 PM, Jari-Pekka Ikonen
> <[email protected]> wrote:
>> Some trigonometric expressions can easily and quickly be simplified without
>> ever calculating some of the functions in it just by using the known
>> properties of the functions in the expression.
>>
>> For example:
>>
>> sin(2*pi)
>>
>> is 0. So:
>>
>> sin(pi*factorial(847937526693730893984732849857349))
>>
>> is also 0. This does not require calculation of the factorial, but the
>> property knowledge, that the result of the factorial is an even integer.
>>
>> There are several other examples of expressions, like:
>>
>> tan(pi*(1342^(87236487262873^(8732498237693269832+3)+5)-1))
>>
>> is also 0. Several others:
>>
>> cos(pi*(factorial(8629264243264^64862423642638763847)+1/2))
>>
>> is 0.
>>
>> Could this be implemented in sympy? So many other examples would be much
>> faster to calculate.
>>
>> --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/218ff008-9f3a-479e-8b4e-bca49d646294%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sympy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sympy/CAKgW%3D6JTFaC9O08ymvq0tLb1p-1Lz2iuWFduCAL-ZSPyby8k0w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CADDwiVAA1PsNQX9W%3DO%3DsPXgdq%3DFJ0cSEeqhsWATGMYoiFmfcgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to