ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 10 Feb 2022 13:38:18 +0100Same code, (vastly) different results locally and at aleph.sagemath.orghttps://ask.sagemath.org/question/61038/same-code-vastly-different-results-locally-and-at-alephsagemathorg/I have SageMath 9.4 for Ubuntu 20.04 downloaded from a french mirror (link) and I am trying to run an LWE estimator (link) by Albrecht et al (link).
### Running on Aleph
Without any problem, I can paste the estimator.py code (link) into Aleph (link), followed by my parameters, e.g.:
n, stdv = 1024, 2^-30.0
set_verbose(1)
_ = estimate_lwe(n, sqrt(2*pi)*stdv, 2^32, reduction_cost_model=BKZ.sieve, secret_distribution=(0,1))
from which I obtain
Warning: the LWE secret is assumed to have Hamming weight 512.
usvp: rop: â‰ˆ2^108.0, red: â‰ˆ2^108.0, Î´_0: 1.005242, Î²: 266, d: 1889, m: 864, repeat: 1, k: 0, postprocess: 0
dec: rop: â‰ˆ2^131.5, m: 1198, red: â‰ˆ2^131.5, Î´_0: 1.004529, Î²: 332, d: 2222, babai: â‰ˆ2^117.5, babai_op: â‰ˆ2^132.6, repeat: 17, Îµ: 0.250000
dual: rop: â‰ˆ2^112.1, m: 994, red: â‰ˆ2^112.1, Î´_0: 1.005070, Î²: 280, repeat: â‰ˆ2^60.8, d: 1986, c: 8, k: 32, postprocess: 1
which tells me that I have 108.0 bits of security (2nd line: `usvp: rop: â‰ˆ2^108.0`). Until here -- fine.
### Running locally
Now I need to process a heap of parameters automatically, which I am trying to run locally (using the aforementioned version of SageMath). Problems arise (with 1-3 possibly irrelevant, 4 indeed relevant):
1. With the very same code I get: `ImportError: cannot import name complex_mpfr`, which seems to be resolved by adding `import sage.all` in the very beginning.
2. Then I get: `n, stdv = 1024, 2^-30.0 .. TypeError: unsupported operand type(s) for ^: 'int' and 'float'` which I fix by replacing `2^-30.0` with `9.3132257e-10`.
3. Next run: `NameError: name 'set_verbose' is not defined` which I solved by importing `from sage.misc.verbose import verbose, set_verbose, get_verbose` (still some warnings -- deprecated stuff and syntax -- which I ignore)
4. Final run: I get the results,
but with completely different numbers:
Warning: the LWE secret is assumed to have Hamming weight 512.
usvp: rop: â‰ˆ2^44.9, red: â‰ˆ2^44.9, Î´_0: 1.013310, Î²: 40, d: 1024, m: -1, repeat: 1, k: 0, postprocess: 0
dec: rop: â‰ˆ2^43.6, m: -614, red: â‰ˆ2^43.6, Î´_0: 1.021759, Î²: 40, d: 410, babai: 1, babai_op: â‰ˆ2^15.1, repeat: 1, Îµ: 1
(and then `TypeError: unable to convert '2.5275472536193645856387667200778292581e-30+2.6845375638424411831060264943943048062e9*I' to a real number` which I ignore)
Compared to 108.0 from Aleph, my local result 44.9 is completely false, though running the same code. I also pasted the modified code into Aleph and it still gives 108.0.
Find my final code at Pastebin (link) (gives results both on Aleph and locally).fakubThu, 10 Feb 2022 13:38:18 +0100https://ask.sagemath.org/question/61038/Why is sagemath real numbers arithmetic gives incorrect result?https://ask.sagemath.org/question/39824/why-is-sagemath-real-numbers-arithmetic-gives-incorrect-result/ I was using Sagemath for computation.
There I was input "152.8-152.43" and gets something like "0.370000000000005". I tried to use RLF and RR too but I could not eliminate the extra number "5" at the end of the result. This raises no problem, since I do not that level of precision, but the number "5" at the end of the result just drives me upset. Why is it so? Is there anyway I can do to eliminate this problem? Matlab gave me the right answer. Is this some kind of weakness of Sagemath? I love Sagemath and intend to stick to it lifelong. But did I go wrong somewhere?michaeldnguyen10Tue, 28 Nov 2017 08:24:06 +0100https://ask.sagemath.org/question/39824/bool returns true to an incorrect function call?https://ask.sagemath.org/question/8173/bool-returns-true-to-an-incorrect-function-call/This happened to me by mistake.
sage: var('x1,t1,x2,t2,u,c',domain=RR);assume(u>0);assume(c>u);assume(x2>x1);assume(t2>t1);
(x1, t1, x2, t2, u, c)
sage: T1 = (t1-((u*x1)/(c^2)))/sqrt(1-((u^2)/(c^2)))
sage: T2 = (t2-((u*x2)/(c^2)))/sqrt(1-((u^2)/(c^2)))
sage: dT = T2-T1
sage: bool(dT.full_simplify >= 0)
True
sage: bool(dT.full_simplify() >= 0)
False
When I made the incorrect function call dT.full_simplify , bool returned true. When I made the correct function call dT.full_simplify() , bool returned false. Is this a bug?
ThanksomoplataMon, 20 Jun 2011 20:18:07 +0200https://ask.sagemath.org/question/8173/