Ask Your Question
3

simplify() does not work?

asked 13 years ago

ryszard314159 gravatar image

updated 13 years ago

kcrisman gravatar image

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...

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
5

answered 13 years ago

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
Preview: (hide)
link

Comments

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

kcrisman gravatar imagekcrisman ( 13 years ago )

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.

John Palmieri gravatar imageJohn Palmieri ( 13 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 977 times

Last updated: May 04 '11