On Fri, Aug 19, 2016 at 11:00 AM, Erik Bray <erik.m.b...@gmail.com> wrote: > On Wed, Aug 10, 2016 at 1:38 PM, Erik Bray <erik.m.b...@gmail.com> wrote: >> Hi all, >> >> Sorry if this has been discussed ad-infinitum before--I looked around >> a bit but didn't find a definitive answer. >> >> I have one (well at least one) test that's failing on Cygwin due to >> tiny difference in the last digit of the result of log(3). >> >> This leads to to several questions: >> >> 1) Is it worth investigating the reason for the difference? >> 2) Is it worth trying to provide a workaround for the difference? >> 3) Or should the test just be updated to ignore the last couple digits >> of the result, and if so how (ellipses?) > > The difference in log(3) strikes again, but this time in a test where > it's harder to just set a tolerance. The test is for the algdep() > method of ComplexDoubleElements: > https://git.sagemath.org/sage.git/tree/src/sage/rings/complex_double.pyx#n2377 > > Because of the way RDF(sqrt(3)) is calculated it uses log(3). This > results in a different numeric result for "z". The test already has > "abs tol 1e-16" for "z" which is fine, but the algorithm from PARI is > sensitive to even that small difference and gives a totally different > polynomial result: > > sage: z = (1/2)*(1 + RDF(sqrt(3)) *CDF.0); z > 0.5 + 0.8660254037844386*I > sage: p = z.algdep(5); p > x^5 + x^2 > sage: z^5 + z^2 > -4.996003610813204e-16 - 2.220446049250313e-16*I > > So the answer isn't wrong--it's still a good approximation. But the > test expects: > > sage: z = (1/2)*(1 + RDF(sqrt(3)) *CDF.0); z > 0.5 + 0.8660254037844387*I > sage: p = z.algdep(5); p > x^3 + 1 > > Not really sure what the best course of action would be for this test > then, other than to hard-code a value for z.
To answer my own question, this is how I rewrote the test for now: 2389 sage: z = (1/2)*(1 + RDF(sqrt(3)) *CDF.0); z # abs tol 1e-16 2390 0.5 + 0.8660254037844387*I 2391 sage: p = z.algdep(5); p # random 2392 x^3 + 1 2393 sage: p.factor() 2394 (x + 1) * ... (x^2 - x + 1) 2395 sage: abs(z^2 - z + 1) < 1e-14 2396 True This works out fine because the result I got still has (x^2 - x + 1) as a factor. It just has one additional factor of x^2. I'm not too happy with marking the result of z.algdep() as "random" though. It's definitely deterministic, just sensitive. I think the doctest module maybe needs an "# ignore" flag that is effectively the same as "# random" without the implication that the output is truly random. Just that the line should be run, but its output should not be checked. -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To post to this group, send email to sage-devel@googlegroups.com. Visit this group at https://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.