Ask Your Question

Simplify expression with root

asked 2020-12-24 21:20:12 +0200

Oscar de Lama gravatar image

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


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 flag offensive close merge delete


Welcome to Ask Sage! Thank you for your question!

slelievre gravatar imageslelievre ( 2020-12-25 01:09:52 +0200 )edit

2 Answers

Sort by » oldest newest most voted

answered 2021-01-04 13:59:54 +0200

dan_fulea gravatar image

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


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

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.

edit flag offensive delete link more

answered 2020-12-25 01:04:53 +0200

slelievre gravatar image

updated 2020-12-25 01:08:17 +0200

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

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
edit flag offensive delete link more


Great! Thanks a lot!

Oscar de Lama gravatar imageOscar de Lama ( 2021-01-03 04:14:10 +0200 )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.

slelievre gravatar imageslelievre ( 2021-01-03 15:40:08 +0200 )edit

Nice and smart...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2021-01-04 17:12:47 +0200 )edit

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


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

Seen: 401 times

Last updated: Jan 04 '21