Ask Your Question

How to Rationalize the Denominator of a Fraction ?

asked 2011-10-08 20:25:35 -0500

supertat gravatar image

updated 2011-10-09 11:38:40 -0500

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.

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2011-10-11 05:08:15 -0500

kcrisman gravatar image

Combining the two answers, I get:

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

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

edit flag offensive delete link more


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')
Sukrit-Gupta gravatar imageSukrit-Gupta ( 2016-05-14 06:01:18 -0500 )edit

answered 2011-10-10 07:14:23 -0500

kcrisman gravatar image

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_()
sage: A = a._maxima_()
sage: A.parent()
sage: A.parent().eval('algebraic:true;')
sage: a.maxima_methods().ratsimp()
-2*sqrt(2) + 3
edit flag offensive delete link more

answered 2011-10-10 16:29:55 -0500

supertat gravatar image

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.

edit flag offensive delete link more


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

kcrisman gravatar imagekcrisman ( 2011-10-11 05:07:28 -0500 )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


Asked: 2011-10-08 20:25:35 -0500

Seen: 2,028 times

Last updated: Oct 11 '11