Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer overflow in Simplify #1290

Open
kkrutkowski opened this issue Sep 28, 2024 · 0 comments
Open

Integer overflow in Simplify #1290

kkrutkowski opened this issue Sep 28, 2024 · 0 comments

Comments

@kkrutkowski
Copy link

kkrutkowski commented Sep 28, 2024

With some relatively long expressions (like the example) even despite using BigInt type for all the constants, Julia returns 64-bit overflow during simplification. The code looks like this:

using Symbolics
@variables YC2 YS2 C2 S2 C2S2 C2C2 S2S2 C2C C2S S2S S2C YC YS CC CS SS C S Y

expressions_array =
    [
    (YC2 - YS2*C2C2/C2S2 - (C2S2 - S2S2*C2C2/C2S2)*(YC - YS2*C2C/C2S2)/(S2C - C2C*S2S2/C2S2) - (YS - YS2*C2S/C2S2 - (YC - YS2*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))*(C2C - S2C*C2C2/C2S2 - (C2S2 - S2S2*C2C2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2)) - (Y - C2*YS2/C2S2 - (S2 - C2*S2S2/C2S2)*(YC - YS2*C2C/C2S2)/(S2C - C2C*S2S2/C2S2) - (YS - YS2*C2S/C2S2 - (YC - YS2*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))*(C - C2*S2C/C2S2 - (S2 - C2*S2S2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2)))*(C2S - S2S*C2C2/C2S2 - (C2S2 - S2S2*C2C2/C2S2)*(CS - S2S*C2C/C2S2)/(S2C - C2C*S2S2/C2S2) - (C2C - S2C*C2C2/C2S2 - (C2S2 - S2S2*C2C2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))*(SS - S2S*C2S/C2S2 - (CS - S2S*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2)))/(S - C2*S2S/C2S2 - (S2 - C2*S2S2/C2S2)*(CS - S2S*C2C/C2S2)/(S2C - C2C*S2S2/C2S2) - (SS - S2S*C2S/C2S2 - (CS - S2S*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))*(C - C2*S2C/C2S2 - (S2 - C2*S2S2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))))
    /
    (C2 - S2*C2C2/C2S2 - (C - S2*C2C/C2S2)*(C2S2 - S2S2*C2C2/C2S2)/(S2C - C2C*S2S2/C2S2) - (C2C - S2C*C2C2/C2S2 - (C2S2 - S2S2*C2C2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))*(S - S2*C2S/C2S2 - (C - S2*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2)) - (1 - S2*C2/C2S2 - (C - S2*C2C/C2S2)*(S2 - C2*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2) - (S - S2*C2S/C2S2 - (C - S2*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))*(C - C2*S2C/C2S2 - (S2 - C2*S2S2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2)))*(C2S - S2S*C2C2/C2S2 - (C2S2 - S2S2*C2C2/C2S2)*(CS - S2S*C2C/C2S2)/(S2C - C2C*S2S2/C2S2) - (C2C - S2C*C2C2/C2S2 - (C2S2 - S2S2*C2C2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))*(SS - S2S*C2S/C2S2 - (CS - S2S*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2)))/(S - C2*S2S/C2S2 - (S2 - C2*S2S2/C2S2)*(CS - S2S*C2C/C2S2)/(S2C - C2C*S2S2/C2S2) - (SS - S2S*C2S/C2S2 - (CS - S2S*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))*(C - C2*S2C/C2S2 - (S2 - C2*S2S2/C2S2)*(CC - S2C*C2C/C2S2)/(S2C - C2C*S2S2/C2S2))/(CS - S2C*C2S/C2S2 - (CC - S2C*C2C/C2S2)*(S2S - C2S*S2S2/C2S2)/(S2C - C2C*S2S2/C2S2))))
    ]

simplified_expressions = [Symbolics.simplify(expr, expand=true, threaded=true, thread_subtree_cutoff=100) for expr in expressions_array]

println(simplified_expressions[1])

I've attached the log of the error as a text file below.
overflow_log.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant