Ask Your Question
0

Converting Polynomials to equations

asked 2024-08-14 15:42:07 +0100

Squarevenouz gravatar image

updated 2024-08-14 16:46:22 +0100

dan_fulea gravatar image

I'm trying to convert polynomials in mod 2 to equations to solve the system of equations. But when I try to convert them they keep evaluating to False and I don't know what I am doing wrong.

R = PolynomialRing(Integers(2), 'b0_1_1, b0_1_2, b0_2_1, b0_2_2, b1_1_1, b1_1_2, b1_2_1, b1_2_2')
b0_1_1, b0_1_2, b0_2_1, b0_2_2, b1_1_1, b1_1_2, b1_2_1, b1_2_2 = R.gens()

poly1 = b0_1_2 + b1_1_1 + b1_2_1
poly2 = b0_1_1 + b0_1_2 + b1_1_2 + b1_2_2 + 1
poly3 = b0_2_2 + b1_1_1
poly4 = b0_2_1 + b0_2_2 + b1_1_2

equations = [poly == 0 for poly in [poly1, poly2, poly3, poly4]]
edit retag flag offensive close merge delete

Comments

1

You can work with the ideal generated by these polynomials for all needed purposes...

dan_fulea gravatar imagedan_fulea ( 2024-08-14 16:47:14 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2024-08-14 17:47:45 +0100

Emmanuel Charpentier gravatar image

I don't know what I am doing wrong

Your polyx variables have values in R1. polyx==0 means "compare value of poly1 with the integer 0", and this cannot return but False

What confuses you is that, the == is overloaded for symbolic expression (SR) operands, and returns a spetial type of symbolic expression, an equation. What you have in mind is something along the lines of :

sage: SR(str(poly1))==0
b0_1_2 + b1_1_1 + b1_2_1 == 0

Here, this expression can be interpreted as "Apply the (infix) == operator to its left and right arguments (coercible to) symbolic expressions", returning an equation.

Such an overload does not exist for polynomial rings. BTW, while the concept of an "equation" object is sometimes useful (e. g. to work separately in the left- and right-hand sides), it is more syntactic sugar than really useful for computational purposes, and exists probably for historical reasons.

As noted by @dan_fulea, a polynomial is also an implicit equation to 0.

BTW, this is true also for symbolic expressions : compare

sage: solve(log(x)==0, x)
[x == 1]

with

sage: solve(log(x), x)
[x == 1]

HTH,

edit flag offensive delete link more

Comments

Instead of SR(str(poly1)) one can use simply SR(poly1).

Max Alekseyev gravatar imageMax Alekseyev ( 2024-08-14 19:37:33 +0100 )edit

Instead of SR(str(poly1)) one can use simply SR(poly1).

Nope :

sage: SR(poly1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

[ Snip... ]

TypeError: no canonical coercion from Symbolic Ring to Multivariate Polynomial Ring in b0_1_1, b0_1_2, b0_2_1, b0_2_2, b1_1_1, b1_1_2, b1_2_1, b1_2_2 over Ring of integers modulo 2

During handling of the above exception, another exception occurred:

[ Re-snip...]

TypeError: unsupported operand parent(s) for *: 'Ring of integers modulo 2' and 'Symbolic Ring'
Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-08-14 21:35:50 +0100 )edit

Ok,, I didn't notice the ring. SR(poly1.change_ring(ZZ)) should do the job then.

Max Alekseyev gravatar imageMax Alekseyev ( 2024-08-15 15:47:48 +0100 )edit

SR(poly1.change_ring(ZZ)) should do the job then.

Indeed.

HTH,

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2024-08-16 09:36:12 +0100 )edit

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2024-08-14 15:42:07 +0100

Seen: 236 times

Last updated: Aug 14