Ask Your Question

simplifying a symbolic expression

asked 2020-06-04 01:01:15 -0500

iozen gravatar image

updated 2020-06-04 01:53:01 -0500

FrédéricC gravatar image

Hi I am really tired of not being able to see that sage says the following expression is zero. Instead it returns the same expression. Please help how to make sure that I get 0 for the calculation. Thank you.

q= var('q',domain='positive');

n= var('n',domain='positive');

k= var('k',domain='positive');

x= var('x',domain='positive');

(((q - 1)*x + 1)^n*q^n - ((q^2 - q)*x + q)^n).simplify_full()

((q - 1)*x + 1)^n*q^n - ((q^2 - q)*x + q)^n
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2020-06-04 03:42:09 -0500

Emmanuel Charpentier gravatar image


sage: var("q,n,k,x", domain="positive")
(q, n, k, x)
sage: (((q - 1)*x + 1)^n*q^n - ((q^2 - q)*x + q)^n).canonicalize_radical()

The canonicalize_radical method is often relevant for symbolic expressions involving powers or radicals. Note however that this method may not be always legitimate (see its docs...).

edit flag offensive delete link more


Thank you very much Emmanuel Carpentier. I tried this in the main problem (the above version was the simplified version) it works like a charm.

iozen gravatar imageiozen ( 2020-06-04 04:05:03 -0500 )edit

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2020-06-04 01:01:15 -0500

Seen: 61 times

Last updated: Jun 04