Ask Your Question

Revision history [back]

The error message is incomplete, it should say "symbolic variable" instead. Indeed, x0 is not a symbolic variable (an element of the symbolic ring) but a polynomial variable (an element of a polynomial ring).

If you want to use symbolic functionality like solve, you can do the explicit conversions:

solution = solve([SR(eq) for eq in equations], [SR(v) for v in P.gens()])
print(solution)

Output:

[
[x0 == r1 - 1/3, x1 == -2*r1 + 2/3, x2 == r1]
]

For this particular problem one could also use linear algebra functionality directly:

sage: M.solve_right(v)
(-1/3, 2/3, 0)
sage: M.right_kernel().basis()
[
(1, -2, 1)
]

which gives the same information in a different way (in particular, without using symbolic variables).