Thanks for your reply! I had done just what you recommended.
I then coded a loop to successively take off leading polynomial terms and,
for each one, print the floating point approximation of the rational polynomial.
Seth

________________________________________
From: sage-support@googlegroups.com <sage-support@googlegroups.com> on behalf 
of Dima Pasechnik <dimp...@gmail.com>
Sent: Wednesday, March 5, 2025 3:38 PM
To: sage-support@googlegroups.com
Subject: Re: [sage-support] Bug Polynomial Quotient with 2 ideal generator 
rings over RR lose precision of base ring.

On Wed, Mar 5, 2025 at 12:51 PM Seth Chaiken <schai...@albany.edu> wrote:
>
> In Sage 10.4, we tried to inject a RR number into a RR polynomial ring 
> quotient.  It
> works fine when the ideal had one (monomial) generator but precision is lost 
> when
> it had two generators.

It's not a bug - it's half-expected that any nontrivial algebraic
computations in PolynomialRing(RR)
will fail due to rounding errors/loss of precision.
You can increase the precision of the ring, and try again, but I'd
recommend avoiding this if at all possible.
Use exact rings instead. E.g. approximate your data by rationals and
use PolynomialRing(QQ).

HTH
Dima

>
> One generator example (works):
>
> eps = var("eps")
> edBaseRing=PolynomialRing(RR,[eps])
> edIdeal=ideal(edBaseRing, [eps])
> edRing=edBaseRing.quotient_ring(edIdeal)
> print(RR(pi))
> print(edBaseRing(pi))
> print(edRing(pi))
>
> yields:
> 3.14159265358979
> 3.14159265358979
> 3.14159265358979
>
> But with 2 generators, injecting RR(pi) into the quotient loses precision.
> The analogous output is:
> 3.14159265358979
> 3.14159265358979
> 3.14200000000000
>
> Here's the full code:
>
> eps, dlt = var("eps,dlt")
> edBaseRing=PolynomialRing(RR,[eps, dlt])
> edIdeal=ideal(edBaseRing, [eps, dlt])
> edRing=edBaseRing.quotient_ring(edIdeal)
>
> print(RR(pi))
> print(edBaseRing(pi))
> print(edRing(pi))
>
> Looks like a bug! I isolated it from more complex code where the ideal was 
> simply all multiples of the two variables, and a RealField with non-default 
> bit precision was used.
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-support+unsubscr...@googlegroups.com.
> To view this discussion visit 
> https://groups.google.com/d/msgid/sage-support/cf40d022-a05e-4269-8612-ed705590c699n%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google 
Groups "sage-support" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/sage-support/gbBYEbxv8Ow/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
sage-support+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/sage-support/CAAWYfq1VREBtd9Ai76%2BM0CtE3vtDaqBMq1kzy5HnmCyftY%3D%2BsA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/sage-support/PH7PR04MB85083EDFD43AA1CCBADD92E6A9CB2%40PH7PR04MB8508.namprd04.prod.outlook.com.

Reply via email to