Ask Your Question
0

Determine rationality of an expression?

asked 2014-02-20 22:49:58 +0100

Jeremie gravatar image

updated 2014-03-30 16:03:57 +0100

tmonteil gravatar image

I am trying to determine whether an expression is rational or not - and if it rational, to get the numerator and denominator.

To give you some context, I first use "solve" to get a [ x == ..., y == ... ] solution, and then I compute log(solution[x])/log(solution[y]). In some cases, this expression is a rational. I would like to be able to determine when it is a rational.

Of course it is rational in some very predictable cases - i.e., when the two logarithms are commensurate, and there are ways of checking this on the value of solution[x] and solution[y] themselves. But I am hoping that sage can do this for me.

I tried to do Rational((log(...)/log(...)).n()) or (log(...)/log(...)).n() in QQ, but of course that does not work, as .n() converts the expression to some arbitrary precision float. Doing (log(...)/log(...)) in QQ always returns False even, for instance, for the case (log(100)/log(10)) = 2.

How can I do this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-03-22 04:38:29 +0100

ndomes gravatar image

updated 2014-03-22 04:39:00 +0100

a = log(8)/log(32)
c = a.simplify_exp()
a; a in QQ; c; c in QQ
edit flag offensive delete link more

Comments

It is strange that "a in QQ" is False while "c in QQ" is True... moreover "a == c" is true !!!

vdelecroix gravatar imagevdelecroix ( 2014-03-22 10:18:37 +0100 )edit

The problem here is that the symbolic ring answers "False" when it does not know the answer.

tmonteil gravatar imagetmonteil ( 2014-03-25 16:10:56 +0100 )edit
0

answered 2014-03-23 18:35:01 +0100

ndomes gravatar image

Indeed, it is strange.

sage:log(8.0)/log(32.0) in QQ; 
True
sage: log(8.0).parent()
Real Field with 53 bits of precision

As far as I can see the trouble comes from the Symbolic Ring.

sage:log(8)/log(32) in QQ; 
False
sage: log(8).parent()
Symbolic Ring
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: 2014-02-20 22:49:58 +0100

Seen: 822 times

Last updated: Mar 23 '14