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.Mon, 04 Jan 2021 17:12:47 +0100Simplify expression with roothttps://ask.sagemath.org/question/54885/simplify-expression-with-root/ The result of some integral, computed using integrate(), is:
2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
However, when I do the integral "by hand" I get
2*(3-2*sqrt(2))
Numerically both results are the same, but the first result is a lot more complicated.
Multiplying separately the numerator and denominator of the first expression by (408*sqrt(2) + 577) brings the correct result.
What can I do to simplify the first expression and get something really simple, as the second one?
Thanks in advance!Thu, 24 Dec 2020 21:20:12 +0100https://ask.sagemath.org/question/54885/simplify-expression-with-root/Comment by slelievre for <p>The result of some integral, computed using integrate(), is:</p>
<pre><code>2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
</code></pre>
<p>However, when I do the integral "by hand" I get </p>
<pre><code>2*(3-2*sqrt(2))
</code></pre>
<p>Numerically both results are the same, but the first result is a lot more complicated.</p>
<p>Multiplying separately the numerator and denominator of the first expression by (408*sqrt(2) + 577) brings the correct result. </p>
<p>What can I do to simplify the first expression and get something really simple, as the second one?</p>
<p>Thanks in advance!</p>
https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=54889#post-id-54889Welcome to Ask Sage! Thank you for your question!Fri, 25 Dec 2020 01:09:52 +0100https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=54889#post-id-54889Answer by dan_fulea for <p>The result of some integral, computed using integrate(), is:</p>
<pre><code>2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
</code></pre>
<p>However, when I do the integral "by hand" I get </p>
<pre><code>2*(3-2*sqrt(2))
</code></pre>
<p>Numerically both results are the same, but the first result is a lot more complicated.</p>
<p>Multiplying separately the numerator and denominator of the first expression by (408*sqrt(2) + 577) brings the correct result. </p>
<p>What can I do to simplify the first expression and get something really simple, as the second one?</p>
<p>Thanks in advance!</p>
https://ask.sagemath.org/question/54885/simplify-expression-with-root/?answer=55096#post-id-55096The answer of [slelievre](https://ask.sagemath.org/users/1092/slelievre/) is already the best one can do in such situations, without taking a piece of paper and writing down the explicit amplification with the conjugate of the denominator
$$
\frac{2(2378\sqrt 2-3363)}{408\sqrt 2-557}=
\frac{2(2378\sqrt 2-3363)(-408\sqrt 2-557)}{(408\sqrt 2-557)(-408\sqrt 2-557)}
$$
and computing the numerator and the denominator explicitly (by hand or using sage).
Alternatively:
- Ask for the minimal polynomial of the given expression.
- Use the conversion to the number field $\Bbb Q(\sqrt 2)$. (With care for other number fields, i.e. in this example check that $\sqrt 2>0$ is correctly taken as the "value" of the generator...)
In code:
sage: u = 2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
sage: var('x');
sage: solve(u.minpoly()(x) == 0, x)
[x == -4*sqrt(2) + 6, x == 4*sqrt(2) + 6]
sage: u.n()
0.343145749747913
sage: K.<a> = QuadraticField(2)
sage: K
Number Field in a with defining polynomial x^2 - 2 with a = 1.414213562373095?
sage: K(u)
-4*a + 6
Please consider accepting [slelievre](https://ask.sagemath.org/users/1092/slelievre/)'s answer, this makes order in the list of the many posts, so that there is no need for potential helpers to look inside of questions with already good answers.
Mon, 04 Jan 2021 13:59:54 +0100https://ask.sagemath.org/question/54885/simplify-expression-with-root/?answer=55096#post-id-55096Answer by slelievre for <p>The result of some integral, computed using integrate(), is:</p>
<pre><code>2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
</code></pre>
<p>However, when I do the integral "by hand" I get </p>
<pre><code>2*(3-2*sqrt(2))
</code></pre>
<p>Numerically both results are the same, but the first result is a lot more complicated.</p>
<p>Multiplying separately the numerator and denominator of the first expression by (408*sqrt(2) + 577) brings the correct result. </p>
<p>What can I do to simplify the first expression and get something really simple, as the second one?</p>
<p>Thanks in advance!</p>
https://ask.sagemath.org/question/54885/simplify-expression-with-root/?answer=54887#post-id-54887One way to simplify this expression is in two steps:
- turn it into an algebraic number
- then transform that algebraic number back into a symbolic expression
Here is how to do that.
Name the expression:
sage: a = 2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
Turn it into an algebraic number:
sage: b = AA(a)
sage: b
0.343145750507?
Turn that algebraic number into a symbolic expression:
sage: c = b.radical_expression()
sage: c
-4*sqrt(2) + 6
Or all in one go:
sage: AA(a).radical_expression()
-4*sqrt(2) + 6Fri, 25 Dec 2020 01:04:53 +0100https://ask.sagemath.org/question/54885/simplify-expression-with-root/?answer=54887#post-id-54887Comment by Oscar de Lama for <p>One way to simplify this expression is in two steps:</p>
<ul>
<li>turn it into an algebraic number</li>
<li>then transform that algebraic number back into a symbolic expression</li>
</ul>
<p>Here is how to do that.</p>
<p>Name the expression:</p>
<pre><code>sage: a = 2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
</code></pre>
<p>Turn it into an algebraic number:</p>
<pre><code>sage: b = AA(a)
sage: b
0.343145750507?
</code></pre>
<p>Turn that algebraic number into a symbolic expression:</p>
<pre><code>sage: c = b.radical_expression()
sage: c
-4*sqrt(2) + 6
</code></pre>
<p>Or all in one go:</p>
<pre><code>sage: AA(a).radical_expression()
-4*sqrt(2) + 6
</code></pre>
https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=55078#post-id-55078Great! Thanks a lot!Sun, 03 Jan 2021 04:14:10 +0100https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=55078#post-id-55078Comment by slelievre for <p>One way to simplify this expression is in two steps:</p>
<ul>
<li>turn it into an algebraic number</li>
<li>then transform that algebraic number back into a symbolic expression</li>
</ul>
<p>Here is how to do that.</p>
<p>Name the expression:</p>
<pre><code>sage: a = 2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
</code></pre>
<p>Turn it into an algebraic number:</p>
<pre><code>sage: b = AA(a)
sage: b
0.343145750507?
</code></pre>
<p>Turn that algebraic number into a symbolic expression:</p>
<pre><code>sage: c = b.radical_expression()
sage: c
-4*sqrt(2) + 6
</code></pre>
<p>Or all in one go:</p>
<pre><code>sage: AA(a).radical_expression()
-4*sqrt(2) + 6
</code></pre>
https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=55081#post-id-55081Glad I could help!
Consider accepting the answer.
This is done by clicking the "accept" button, the button
consisting of a tick mark "✓" icon, located to the left of
the top of the answer, below the "upvote" and "downvote"
buttons and the answer's score.
This marks the question as solved in the list of questions.
This saves time for people looking for unsolved questions to answer.Sun, 03 Jan 2021 15:40:08 +0100https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=55081#post-id-55081Comment by Emmanuel Charpentier for <p>One way to simplify this expression is in two steps:</p>
<ul>
<li>turn it into an algebraic number</li>
<li>then transform that algebraic number back into a symbolic expression</li>
</ul>
<p>Here is how to do that.</p>
<p>Name the expression:</p>
<pre><code>sage: a = 2*(2378*sqrt(2) - 3363)/(408*sqrt(2) - 577)
</code></pre>
<p>Turn it into an algebraic number:</p>
<pre><code>sage: b = AA(a)
sage: b
0.343145750507?
</code></pre>
<p>Turn that algebraic number into a symbolic expression:</p>
<pre><code>sage: c = b.radical_expression()
sage: c
-4*sqrt(2) + 6
</code></pre>
<p>Or all in one go:</p>
<pre><code>sage: AA(a).radical_expression()
-4*sqrt(2) + 6
</code></pre>
https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=55104#post-id-55104Nice and smart...Mon, 04 Jan 2021 17:12:47 +0100https://ask.sagemath.org/question/54885/simplify-expression-with-root/?comment=55104#post-id-55104