Is y a power of x? Rather than computing logarithms (floating point can betray you), divide repeatedly:
while y % x == 0:
y //= x
return y == 1
Or multiply upward: start at p = 1 and keep doing p *= x while p < y, then check p == y.
Edge cases decide correctness here. x = 1 would loop forever in the multiply version, since the only power of 1 is 1. And y = 1 is always x⁰.