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.Sat, 07 Sep 2024 16:38:10 +0200Canonicalize radical not simplifying expressionhttps://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/I have the expression
`7/6528*(103*sqrt(sqrt(17) + 17)*(sqrt(17) - 17) + 252*sqrt(17)*sqrt(-sqrt(17) + 17))/(sqrt(sqrt(17) + 17)*(sqrt(17) - 17))`, which I know is a rational number based on a theorem proved from a paper. In fact, it is supposed to equal `35/816`. However, SageMath does not simplify this to a rational number with `full_simplify()` or with `canonicalize_radical()`.
How do I force SageMath to simplify this properly?Tue, 03 Sep 2024 22:59:30 +0200https://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/Answer by Emmanuel Charpentier for <p>I have the expression
<code>7/6528*(103*sqrt(sqrt(17) + 17)*(sqrt(17) - 17) + 252*sqrt(17)*sqrt(-sqrt(17) + 17))/(sqrt(sqrt(17) + 17)*(sqrt(17) - 17))</code>, which I know is a rational number based on a theorem proved from a paper. In fact, it is supposed to equal <code>35/816</code>. However, SageMath does not simplify this to a rational number with <code>full_simplify()</code> or with <code>canonicalize_radical()</code>. </p>
<p>How do I force SageMath to simplify this properly?</p>
https://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/?answer=79084#post-id-79084Alternatives to @Max Alekseyev's excellent answer :
sage: s._giac_().simplify()
35/816
# Gratis-but-not-free Wolfram Engine :
sage: s._mathematica_().FullSimplify()
35/816
HTH,
Thu, 05 Sep 2024 10:29:12 +0200https://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/?answer=79084#post-id-79084Comment by eric_g for <p>Alternatives to <a href="/users/26682/max-alekseyev/">@Max Alekseyev</a>'s excellent answer :</p>
<pre><code>sage: s._giac_().simplify()
35/816
# Gratis-but-not-free Wolfram Engine :
sage: s._mathematica_().FullSimplify()
35/816
</code></pre>
<p>HTH,</p>
https://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/?comment=79110#post-id-79110An alternative to invoke `giac`'s simplification:
sage: simplify(s, algorithm='giac')
35/816Sat, 07 Sep 2024 16:38:10 +0200https://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/?comment=79110#post-id-79110Answer by Max Alekseyev for <p>I have the expression
<code>7/6528*(103*sqrt(sqrt(17) + 17)*(sqrt(17) - 17) + 252*sqrt(17)*sqrt(-sqrt(17) + 17))/(sqrt(sqrt(17) + 17)*(sqrt(17) - 17))</code>, which I know is a rational number based on a theorem proved from a paper. In fact, it is supposed to equal <code>35/816</code>. However, SageMath does not simplify this to a rational number with <code>full_simplify()</code> or with <code>canonicalize_radical()</code>. </p>
<p>How do I force SageMath to simplify this properly?</p>
https://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/?answer=79038#post-id-79038Converting expession to an algebraic number and computing its radical expression does the trick here:
s = 7/6528*(103*sqrt(sqrt(17) + 17)*(sqrt(17) - 17) + 252*sqrt(17)*sqrt(-sqrt(17) + 17))/(sqrt(sqrt(17) + 17)*(sqrt(17) - 17))
print( QQbar(s).radical_expression() )Wed, 04 Sep 2024 01:15:57 +0200https://ask.sagemath.org/question/79037/canonicalize-radical-not-simplifying-expression/?answer=79038#post-id-79038