Ask Your Question

Revision history [back]

Print multiplication (*) operator

Problem Description The problem that I am facing is that I want to parse the output of sage into another file. Currently I am executing sage command to run a sage file, and then using the output of the sage file for another purpose. The issue with the output is that the space symbol is used for both multiplication and in general space. How to use '' or some other symbol for multiplication in 'sage'? For example when I run the following sage file:

var('x')
var('a')
var('b')
var('r')
var('tmp')
qf = qepcad_formula
constr0 = (tmp - tmp +(Rational(1/1) (x^2)* (a^2)) + (Rational(1/1)* (b^2)) + (Rational(-1/1)* (a^2)* (b^2)) < 0)
constr1 = (tmp - tmp +(Rational(1/1)* (x^2)) + (Rational(221/1)) + (Rational(-20/1)* (x)) + (Rational(-1/1)* (r^2)) < 0)
F1 = qf.and_(constr0, constr1)
F3 =F1
print(qepcad(qf.exists(x,F3)))

I get the output as:

a - 1 /= 0 /\ a + 1 /= 0 /\ b /= 0 /\ r - 11 /= 0 /\ r + 11 /= 0 /\ [ a^4 r^4 - 2 a^4 b^2 r^2 + 2 a^2 b^2 r^2 - 442 a^4 r^2 + a^4 b^4 - 2 a^2 b^4 + b^4 + 42 a^4 b^2 - 42 a^2 b^2 + 48841 a^4 < 0 / [ a - 1 > 0 /\ a^2 r^2 - a^2 b^2 + b^2 - 221 a^2 > 0 ] / [ a + 1 < 0 /\ a^2 r^2 - a^2 b^2 + b^2 - 221 a^2 > 0 ] / [ a^2 b^2 - b^2 - 100 a^2 > 0 /\ r - 11 > 0 ] / [ a^2 b^2 - b^2 - 100 a^2 > 0 /\ r + 11 < 0 ] ]

Here it would be great if multiplication operator * is used for multiplication. Is there any way to do this in sage right now? I would like the print operator to output * instead for multiplication by space.

Proposed Solution:

The print function should allow the use of '*' operator for multiplication.

click to hide/show revision 2
retagged

Print multiplication (*) operator

Problem Description The problem that I am facing is that I want to parse the output of sage into another file. Currently I am executing sage command to run a sage file, and then using the output of the sage file for another purpose. The issue with the output is that the space symbol is used for both multiplication and in general space. How to use '' or some other symbol for multiplication in 'sage'? For example when I run the following sage file:

var('x')
var('a')
var('b')
var('r')
var('tmp')
qf = qepcad_formula
constr0 = (tmp - tmp +(Rational(1/1) (x^2)* (a^2)) + (Rational(1/1)* (b^2)) + (Rational(-1/1)* (a^2)* (b^2)) < 0)
constr1 = (tmp - tmp +(Rational(1/1)* (x^2)) + (Rational(221/1)) + (Rational(-20/1)* (x)) + (Rational(-1/1)* (r^2)) < 0)
F1 = qf.and_(constr0, constr1)
F3 =F1
print(qepcad(qf.exists(x,F3)))

I get the output as:

a - 1 /= 0 /\ a + 1 /= 0 /\ b /= 0 /\ r - 11 /= 0 /\ r + 11 /= 0 /\ [ a^4 r^4 - 2 a^4 b^2 r^2 + 2 a^2 b^2 r^2 - 442 a^4 r^2 + a^4 b^4 - 2 a^2 b^4 + b^4 + 42 a^4 b^2 - 42 a^2 b^2 + 48841 a^4 < 0 / [ a - 1 > 0 /\ a^2 r^2 - a^2 b^2 + b^2 - 221 a^2 > 0 ] / [ a + 1 < 0 /\ a^2 r^2 - a^2 b^2 + b^2 - 221 a^2 > 0 ] / [ a^2 b^2 - b^2 - 100 a^2 > 0 /\ r - 11 > 0 ] / [ a^2 b^2 - b^2 - 100 a^2 > 0 /\ r + 11 < 0 ] ]

Here it would be great if multiplication operator * is used for multiplication. Is there any way to do this in sage right now? I would like the print operator to output * instead for multiplication by space.

Proposed Solution:

The print function should allow the use of '*' operator for multiplication.