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

Error: Simple expressions can yield outputs with more than 4300 characters #1304

Open
RandomDude4 opened this issue Jul 2, 2024 · 1 comment

Comments

@RandomDude4
Copy link

The bug seems to be related to the relatively new addition to python "sys.set_int_max_str_digits()" which I am not sure if it is possible to change within Octave.
See example 3 below for something that is easily calculated without symbolic package, but fails in the symbolic package due to incorrect generation of too many digits.

Simple example 1:

sym('0.001^10000')

error: Python exception: ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit occurred while copying variables from Python.

Because it tries to type out "1/100000000000000000000000000..." which would be more than 4300 characters.

Using just the string directly in vpa() works without issues, example 2:

vpa('0.001^10000')

ans = (sym) 1.0000000000000000000000000000000e-30000

This causes a problem when trying to use such expressions in functions, example 3:

syms F(p,k)
F(p,k) = p^k;
vpa(F(0.9999, 10000))

error: Python exception: ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit occurred while copying variables from Python.

My understanding is that it is not the vpa() command that throws the error, just the evaluation of the F() function that tries to output an equation (text string?) that has more than 4300 characters.

Notes:
These are all very simple examples, I actually ran into issues when trying to calculate a real combinatoric problem with many factorials and exponents that in the end cancel out to some realistic number, but it required high precision in the intermediate steps.

The final example of 0.9999^10000 = 0.3679 and can be easily calculated without the symbolic package, but the first example with 1e-3000 cannot.

@RandomDude4
Copy link
Author

I forgot to mention that this was tested in the latest version of Octave (9.2.0), and Symbolic Package (3.2.1).

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