ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 04 Jun 2020 11:05:03 +0200simplifying a symbolic expressionhttps://ask.sagemath.org/question/51751/simplifying-a-symbolic-expression/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)^nThu, 04 Jun 2020 08:01:15 +0200https://ask.sagemath.org/question/51751/simplifying-a-symbolic-expression/Answer by Emmanuel Charpentier for <p>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.</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/51751/simplifying-a-symbolic-expression/?answer=51753#post-id-51753Well...
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...).Thu, 04 Jun 2020 10:42:09 +0200https://ask.sagemath.org/question/51751/simplifying-a-symbolic-expression/?answer=51753#post-id-51753Comment by iozen for <p>Well...</p>
<pre><code>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
</code></pre>
<p>The <code>canonicalize_radical</code> method is often relevant for symbolic expressions involving powers or radicals. Note however that this method may not be always legitimate (see its docs...).</p>
https://ask.sagemath.org/question/51751/simplifying-a-symbolic-expression/?comment=51755#post-id-51755Thank you very much Emmanuel Carpentier. I tried this in the main problem (the above version was the simplified version) it works like a charm.Thu, 04 Jun 2020 11:05:03 +0200https://ask.sagemath.org/question/51751/simplifying-a-symbolic-expression/?comment=51755#post-id-51755