Ask Your Question
3

How to Rationalize the Denominator of a Fraction ?

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

supertat gravatar image

updated 2011-10-09 18:38:40 +0200

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

3 Answers

Sort by ยป oldest newest most voted
5

answered 2011-10-11 12:08:15 +0200

kcrisman gravatar image

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.

edit flag offensive delete link 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')
Sukrit-Gupta gravatar imageSukrit-Gupta ( 2016-05-14 13:01:18 +0200 )edit
3

answered 2011-10-10 14:14:23 +0200

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_()
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
edit flag offensive delete link more
1

answered 2011-10-10 23:29:55 +0200

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

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.

kcrisman gravatar imagekcrisman ( 2011-10-11 12:07:28 +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

Stats

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

Seen: 4,294 times

Last updated: Oct 11 '11