I don't believe an equation like that can be solved analytically because in an equation with two unknowns, you would only be solving one in relation to the other.
In short, if you equation is v = x^a*y^b you want to rearrange to solve for a, so that would be:
a = (log(v) - b*log(y)) / log(x)
but as you can see, it is defined in terms of b, which isn't given, so then we iterate through values of b, essentially guessing it, given the result of a.
To define what the search space is you would need to search up to an exponent value, e, such that:
(larger of x and y)^e = v
Here's an example implementation:
from math import log, ceil, fabs
def solver(x, y, v):
# v = x^a*y^b and solving for a and b
if (x > y):
larger = x
else:
larger = y
# figure out upper limit of exponents to search
upper = ceil(log(v) / log(larger))
solutions = []
# loop through values up to upper bound
for i in range(1, upper):
# calculate first exponent
a = (log(v) - i * log(y) ) / log(x)
# early out for exponents that aren't integers
if (fabs(a - round(a)) > 0.0001):
continue
# calculate second exponent from first, check if integer
b = (log(v) - a * log(x) ) / log(y)
if (fabs(b - round(b)) < 0.0001):
# add to possible solutions
solutions.append((round(a), round(b)))
return solutions
print (solver(2, 3, 3888)) # [(4, 5)] ; that is, 2^4*3^5=3888
print (solver(2, 9, 46656)) # [(6, 3)] ; that is, 2^6*9^3=46656
print (solver(2, 3, 40)) # [] ; no solution