Ask Your Question

Can this fraction be simplified ?

asked 2018-04-25 05:08:26 -0500

updated 2018-04-26 10:43:41 -0500

During some calculations, I came across a fraction of this kind :


Which should be equal to $\sqrt{2}$.

I am surprised to see that Sage can't simplify this fraction with simplify_full :

( (sqrt(2)+2)/(sqrt(2)+1) ).simplify_full()

returns the same. Just to be sure:

bool( (sqrt(2)+2)/(sqrt(2)+1) == sqrt(2) )

returns true

Am I missing a simplification option ? How can I get Sage to simplify this fraction ?

To clarify, the original expression I encountered was this one :


which is equal to $\frac{\sqrt{3}}{x}$. Sage can show the equality, but cannot simplify the expression (but maybe it's normal, this is not as trivial as the first example...). Substituting $x=1$ in this formula give something very similar to the expression above.

It can be obtained with:

f = 3*(x^4+4*sqrt(3)*(x^2+6)*sqrt(x^2+3)+24*x^2+72)/(sqrt(3)*(x^5+24*x^3+72*x)+12*(x^3+6*x)*sqrt(x^2+3))
edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2018-04-25 13:34:01 -0500

eric_g gravatar image

updated 2018-04-26 15:28:20 -0500

As a side remark, both SymPy and Giac are able to simplify it:

sage: s = (sqrt(2)+2)/(sqrt(2)+1)
sage: s._sympy_().simplify()
sage: s._giac_().simplify()

EDIT: regarding the large fraction involving the symbolic variable x, only Giac is able to simplify it:

sage: f = 3*(x^4+4*sqrt(3)*(x^2+6)*sqrt(x^2+3)+24*x^2+72)/(sqrt(3)*(x^5+24*x^3+72*x)+12*(x^3+6*x)*sqrt(x^2+3))
sage: f._sympy_().simplify()
(3*x**4 + 72*x**2 + 3*sqrt(3*x**2 + 9)*(4*x**2 + 24) + 216)/(x*(12*sqrt(x**2 + 3)*(x**2 + 6) + sqrt(3)*(x**4 + 24*x**2 + 72)))
sage: f._giac_().simplify()
edit flag offensive delete link more

answered 2018-04-26 04:36:28 -0500

tmonteil gravatar image

updated 2018-04-26 04:37:05 -0500

For another perspective : symbolic expression are too wide so that equaity could not be decided, in particular there can not be a consistent simplification procedure.

However, the expression you are dealing with represents an algebraic number. The field of algebraic numbers is a safer place : the problems above become decidable. So, let me suggest the following approach;

sage: a = (sqrt(2)+2)/(sqrt(2)+1)
sage: a.parent()
Symbolic Ring
sage: b = QQbar(a)
sage: b
sage: b.parent()
Algebraic Field
sage: b.radical_expression()

Note howewer that the radical_expression method is a bit hackish and does not handle the wohle Galois theory (yet).

edit flag offensive delete link more


In fact the fraction I posted was a simplified version of my expression, which also involved symbolic variables. But I figured I'd have no hope if it didn't even work with integers.

Florentin Jaffredo gravatar imageFlorentin Jaffredo ( 2018-04-26 08:15:50 -0500 )edit

Could you please provide the unsimplified version ?

tmonteil gravatar imagetmonteil ( 2018-04-26 09:10:27 -0500 )edit

answered 2018-04-25 14:06:05 -0500

Emmanuel Charpentier gravatar image

Well... The default Sage algorithms aren't always the most efficient.However, one can try :

sage: import sympy
sage: sympy.sympify((sqrt(2)+2)/(sqrt(2)+1)).simplify()._sage_()

We also have :

sage: ((sqrt(2)+2)/(sqrt(2)+1)/sqrt(2)).canonicalize_radical()

as well as :

sage: from giacpy_sage import *
sage: libgiac.simplify((sqrt(2)+2)/(sqrt(2)+1)).sage()

(this one can probably be done more economically...).


edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools


Asked: 2018-04-25 05:08:26 -0500

Seen: 90 times

Last updated: Apr 26