Ask Your Question
1

simplifying a symbolic expression

asked 4 years ago

iozen gravatar image

updated 4 years ago

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

1 Answer

Sort by » oldest newest most voted
2

answered 4 years ago

Emmanuel Charpentier gravatar image

Well...

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()
0

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

Preview: (hide)
link

Comments

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 ( 4 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

1 follower

Stats

Asked: 4 years ago

Seen: 361 times

Last updated: Jun 04 '20