Newbie qepcad.py syntax problem

51 views
Skip to first unread message

Robert Pollak

unread,
Jul 10, 2014, 11:44:25 AM7/10/14
to sage-s...@googlegroups.com, Carl Witty, robert...@jku.at
Dear Mr. Witty,

I am currently researching how to replace Mathematica in our first-year students' lectures.
One of the main emerging topics is how to solve (systems of) rational inequalities. In this context I have just found out about Sage's support of quantifier elimination via QEPCAD and your qepcad.py, which seems to be the way to go.

As an example, I want to solve the inequality "(x-1)/(x-5) <= 1/3" with qepcad.py.

I have to get rid of the fractions, so I get: "( x-5 > 0 and 3(x-1) <= x-5 ) or ( x-5 < 0 and 3(x-1) >= x-5 )".

After reading qepcad.py I tried to translate this to a qepcad call:

qepcad(qepcad_formula.or_(qepcad_formula.and_(x-5 > 0, 3(x-1) <= x-5), qepcad_formula.and_(x-5 < 0, 3(x-1) >= x-5)), vars='(x)')

However, this only yields

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-54920de01e67> in <module>()
----> 1 qepcad(qepcad_formula.or_(qepcad_formula.and_(x-Integer(5) > Integer(0), Integer(3)(x-Integer(1)) <= x-Integer(5)), qepcad_formula.and_(x-Integer(5) < Integer(0), Integer(3)(x-Integer(1)) >= x-Integer(5))), vars='(x)')

TypeError: 'sage.rings.integer.Integer' object is not callable


Can you please help me to compose the correct call?

(Because of http://trac.sagemath.org/ticket/16642 I am currently using http://sagecell.sagemath.org/, which has 'Version B 1.50, 22 May 2008' of qepcad.)

Best regards,
Robert Pollak

Nils Bruin

unread,
Jul 10, 2014, 1:52:41 PM7/10/14
to sage-s...@googlegroups.com, cwi...@newtonlabs.com, robert...@jku.at
On Thursday, July 10, 2014 8:44:25 AM UTC-7, Robert Pollak wrote:
Dear Mr. Witty,

I am currently researching how to replace Mathematica in our first-year students' lectures.
One of the main emerging topics is how to solve (systems of) rational inequalities. In this context I have just found out about Sage's support of quantifier elimination via QEPCAD and your qepcad.py, which seems to be the way to go.

As an example, I want to solve the inequality "(x-1)/(x-5) <= 1/3" with qepcad.py.

I have to get rid of the fractions, so I get: "( x-5 > 0 and 3(x-1) <= x-5 ) or ( x-5 < 0 and 3(x-1) >= x-5 )".

After reading qepcad.py I tried to translate this to a qepcad call:

qepcad(qepcad_formula.or_(qepcad_formula.and_(x-5 > 0, 3(x-1) <= x-5), qepcad_formula.and_(x-5 < 0, 3(x-1) >= x-5)), vars='(x)')

3(x-1) tries to call 3 with the argument x-1. That explains the error you're seeing. Write 3*(x-1) instead.

kcrisman

unread,
Jul 10, 2014, 4:40:51 PM7/10/14
to sage-s...@googlegroups.com


Dear Mr. Witty,


I'm  not sure how active he is currently in Sage, but welcome to sage-support!
 qepcad(qepcad_formula.or_(qepcad_formula.and_(x-5 > 0, 3(x-1) <= x-5), qepcad_formula.and_(x-5 < 0, 3(x-1) >= x-5)), vars='(x)')

I don't know much about how to use QEPCAD, but in this case your problem is more prosaic:

3(x-1) 

Sage can support implicit multiplication but we encourage people not to do so.  3*(x-1) is what you're looking for, and hopefully that will solve your problem!  Good luck.

- kcrisman

Robert Pollak

unread,
Jul 11, 2014, 4:35:51 AM7/11/14
to sage-s...@googlegroups.com
> After reading qepcad.py I tried to translate this to a qepcad call:
>
> qepcad(qepcad_formula.or_(qepcad_formula.and_(x-5 > 0, 3(x-1) <=
> x-5), qepcad_formula.and_(x-5 < 0, 3(x-1) >= x-5)), vars='(x)')
>
>
> 3(x-1) tries to call 3 with the argument x-1. That explains the error
> you're seeing. Write 3*(x-1) instead.

Thank you! And sorry for not finding this by myself. I was confused by
the fact that QEPCAD itself allows implicit multiplication, e.g. this works:

qepcad('3 x - 3 <= x - 5', vars='(x)')

Reply all
Reply to author
Forward
0 new messages