Exponentiation and logarithm with rational input and output

36 Views Asked by At

Does an algorithm $f : ℚ^+ × ℚ \to ℚ^?$ such that:

$$ f(x,y) = \left\{ \begin{array}{ll} \text{Just} \space x^y & \quad \text{if} \quad x^y \in ℚ \\ \text{Nothing} & \quad \text{otherwise} \end{array} \right. $$ exist? If so, how is such algorithm implemented?

Also, is there an analogous algorithm for $\log_xy$ (Provided that $x≠1$)?

1

There are 1 best solutions below

2
On

by necessary conditions, if $y$ doesn't have a denominator $d$ that both numerator and denominator of $x$ are perfect $d$-th powers game over.

Similarly for log to get integers the property is needed for both numerator and denominator of $y$ must be perfect powers of the respective part of $x$ unless they would simplify due to common factors. for all rational parts there must exist a rational exponent you can use to get $x$ to that part.