If you have numpy 1.23 or later, you can use np.emath.logn:
import numpy as np
array = np.array([74088, 3111696]) # = [42^3, 42^4]
base = 42
exponent = np.emath.logn(base, array) # = [3, 4]
If your version of numpy is older:
To get the logarithm with a custom base using math.log
:
import math
number = 74088 # = 42^3
base = 42
exponent = math.log(number, base) # = 3
To get the logarithm with a custom base using numpy.log
:
import numpy as np
array = np.array([74088, 3111696]) # = [42^3, 42^4]
base = 42
exponent = np.log(array) / np.log(base) # = [3, 4]
Which uses the logarithm base change rule: