simplify() does not work?

I enter:

sage: a, b = var('a, b'); simplify((a + b)^2 - a^2 - 2*a*b - b^2)


and I would expect 0 (i.e. zero) as a result from simplify(), but instead I get back unmodified:

(a + b)^2 - a^2 - 2*a*b - b^2


Am I missing anything? I just started using it and it looks very promissing...

edit retag close merge delete

Sort by » oldest newest most voted

There are different simplify functions. Try this:

sage: var('a b')
(a, b)
sage: f = ((a + b)^2 - a^2 - 2*a*b - b^2)
sage: f.simplify()  # as you had
(a + b)^2 - a^2 - 2*a*b - b^2
sage: f.simplify_full()
0

more

To the original poster - note the 'dot' notation in this case, where f.simplify() does the same things as simplify(f).

( 2011-05-04 04:46:55 -0500 )edit

Also note that you can type "f.simplify<tab>" to get a list of functions whose names start with "simplify". Once you've found one, like "f.simplify()" or "f.simplify_full()", I would recommend typing "f.simplify?" or "f.simplify_full?" to read the documentation.

( 2011-05-04 06:13:26 -0500 )edit