Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Determine rationality of an expression?

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?

Determine rationality of an expression?

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?