I need to find integer solutions to the equation a^a + b^b = c^c. I could resort to traditional programming in, say, the Python programming language, where I would use three for loops (followed by some basic mathematical operations) and check to see whether the sum on the left of the equation is exactly equal to the value on the right. Assuming I iterate each of the three loops from 0 to 1000, the program will need to check through a little over 1 billion possible integer combinations (calculated by 1001^3). Due to the symmetry of a^a + b^b, a better optimization would be to only work with scenarios where a<=b, in which case the program will need to check through a little over 502 million possible integer combinations. I can optimize further. Take the sum on the left and attempt to resolve it to c^c. Python’s gmpy2 library will easily do that for us; just iterate the exponent from 2 to log base 2 of the sum (it’s a trick from mathematics). See this example:
import math import gmpy2 gmpy2.get_context().precision=1000 #The higher the better, but slower sum = 285311670611 #Will be obtained from a^a + b^b. This is just an example for c in range(2, round(math.log(sum, 2))+2): result = gmpy2.root(sum, c) #This is where the magic happens! if(result%1==0 and result==c): print(result)
This is great and all but the number of integer combinations increases as the range of a,b increases. So, should I (can I) resort to GPU programming to try and quickly find solutions to the equation? If you have any questions, ask away and I will gladly answer them. Thank you.