Ask Your Question

# How to Rationalize the Denominator of a Fraction ?

Hi, experts.

Is there any way to rationalize the denomintor of a fraction ?

For example, I tried

a = 1 / (2 * sqrt(2) + 3)

b = a.simplify_full(); b;
c = a.simplify_factorial(); c;
d = a.simplify_radical(); d;
e = a.simplify_rational(); e;


expecting any of them to return "3 - 2*sqrt(2)" or "-2*sqrt(2) + 3".

However, all of the above commands return 1/(2*sqrt(2) + 3),
whose denominator is not rational.

I know
(1) Sage uses Maxima.
(2) Standalone version of Maxima can rationalize the denominator by typing "ratsimp(a), algebraic: true;".
(3) Sage accepts "maxima.ratsimp(a)", but I don't know how to pass the Maxima option "algebraic: true;" to Sage.

Is there any way to rationalize the denominator with Sage ?

Thanks in advance.
-Tatsuya

edit retag close merge delete

## 3 Answers

Sort by » oldest newest most voted

Combining the two answers, I get:

sage: a = 1 / (2 * sqrt(2) + 3)
sage: maxima_calculus('algebraic: true;')
true
sage: a.simplify_rational()
-2*sqrt(2) + 3


This is probably as simple as it will get for a while.

more

## Comments

Basically, what are algebraic calculations? or are there any consequences of turning on the algebraic maxima_calculus on precision or general calculations in sage ?

From your below answer, another method to set it to true.

a.maxima_methods().ratsimp('algebraic: true')


The maxima_methods thing is very useful. Unfortunately, I'm not sure how to get the algebraic keyword in other than the way pointed out below. We have to let Maxima evaluate it.

sage: a = 1 / (2 * sqrt(2) + 3)
sage: a.maxima_methods().ratsimp()
1/(2*sqrt(2) + 3)
sage: a
1/(2*sqrt(2) + 3)
sage: a._maxima_()
1/(2^(3/2)+3)
sage: A = a._maxima_()
sage: A.parent()
Maxima_lib
sage: A.parent().eval('algebraic:true;')
'true'
sage: a.maxima_methods().ratsimp()
-2*sqrt(2) + 3

more

Thank you for your reply.
maxima_methods seems to be useful.

I also found another way to set algebraic to true.

sage: maxima('ratsimp(a) algebraic: true')


Though this method seems to send the maxima command as a string to Maxima.

more

## Comments

But did that work for the "calculus copy" of Maxima? I doubt it. Also, I get an error when I use your exact syntax.

## Your Answer

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

Add Answer

## Stats

Asked: 2011-10-09 03:25:35 +0200

Seen: 3,382 times

Last updated: Oct 11 '11