Ask Your Question

# 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!

edit retag close merge delete

## Comments

Welcome to Ask Sage! Thank you for your question!

( 2020-12-25 01:09:52 +0100 )edit

## 2 Answers

Sort by » oldest newest most voted

One 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) + 6

more

## Comments

Great! Thanks a lot!

( 2021-01-03 04:14:10 +0100 )edit

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

( 2021-01-03 15:40:08 +0100 )edit

Nice and smart...

( 2021-01-04 17:12:47 +0100 )edit

The answer of 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'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.

more

## Your Answer

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

Add Answer

## Stats

Asked: 2020-12-24 21:20:12 +0100

Seen: 110 times

Last updated: Jan 04 '21