Ask Your Question
2

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 :

$$\frac{\sqrt{2}+2}{\sqrt{2}+1}$$

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 :

$$\frac{3(x^4+4\sqrt{3}(x^2+6)\sqrt{x^2+3}+24x^2+72)}{\sqrt{3}(x^5+24x^3+72x)+12(x^3+6x)\sqrt{x^2+3}}$$

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
3

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()
sqrt(2)
sage: s._giac_().simplify()
sqrt(2)

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()
sqrt(3)/x
edit flag offensive delete link more
3

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
1.414213562373095?
sage: b.parent()
Algebraic Field
sage: b.radical_expression()
sqrt(2)

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

Comments

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
1

Could you please provide the unsimplified version ?

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

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_()
sqrt(2)

We also have :

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

as well as :

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

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

HTH...

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

Stats

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

Seen: 90 times

Last updated: Apr 26