Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

answered 2012-12-01 06:55:53 -0600

DSM gravatar image

It seems to work fine for me:

sage: var('x')
sage: f=function('f',nargs=1)
sage: f
sage: f == f
sage: f(x) == f(x)
f(x) == f(x)
sage: bool(f(x) == f(x))
sage: if f(x) == f(x):
....:     print 'equal!'

Do you mean that you want f(x) == f(x) to be automatically simplified to True, instead of returning an equation? That can't work in general, because in Sage, an equation is False if Sage can't prove that it's true. So if you had an equation like

sage: x^2 - 4 == 0
x^2 - 4 == 0

it would instead give you False rather than the equation, because it's possible that x is something other than 2 or -2..

Long story short, if you want the truth value, call bool. You might be able to construct a subclass which gives you the behaviour you want but ISTM it'll only lead to headaches.