Ask Your Question

How to work with polynomial rings with real or complex coefficients

asked 2023-04-20 17:06:13 +0200

stillconfused gravatar image

I'm trying to learn more basics in Sage, and I'm struggling with polynomial rings with real and complex coefficients. Many of the basic functions seem to return errors from the Singular or Pari implementation, and I wonder if there is a simple workaround I'm missing. Here is an example:

P.<x,y> = PolynomialRing(RealField(), 2)
I = P.ideal(x^2 - y + 1, -x^2 - y - 1)

Returns an error:

TypeError: cannot call Singular function 'primdecSY' with ring parameter of type '<class 'sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict_domain_with_category'>'

Running the same code with QQ instead of RealField() works fine, so I assume the issue is that the Singular function can't work with Sage's implementation of Real numbers. Is there a way around this to do basic operations on polynomial rings with coefficients in numerically approximated fields like the reals and complexes?

edit retag flag offensive close merge delete



For ideals to work, one needs exact field - like AA or QQbar.

Max Alekseyev gravatar imageMax Alekseyev ( 2023-04-21 02:38:25 +0200 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2023-04-21 17:57:46 +0200

Max Alekseyev gravatar image

updated 2023-04-21 18:18:15 +0200

The problem with real or complex fields is that their elements are approximate, and operations there are subject to rounding errors, which may accumulate with the number of performed operations. This is unacceptable situation for the ideals machinery, where accumulating errors destroy basic properties and make it impossible to perform basis operations (e.g., membership testing).

In other words, for ideals to work they have to be defined over exact fields/rings, which do not allow rounding errors of any kind. Unfortunately, real and complex fields cannot be implemented exactly. Nevertheless, there are suitable substitutes for real and complex fields:

We can approximate real and complex numbers with elements of AA and QQbar using algdep() function, where we can choose accuracy in the form of polynomial degree.

Clearly, rational fields QQ and QQ[I] are subfields of AA and QQbar, respectively, and appear when we approximate with polynomials of degree 1.

For example, we can approximate $\pi$ with a polynomial root of degree 5 as follows:

eps = 1e-6
pi_aa = AA.polynomial_root(algdep(pi,5),RIF(pi-eps,pi+eps))

which gives

Algebraic Real Field
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2023-04-20 17:06:13 +0200

Seen: 196 times

Last updated: Apr 21 '23