I'm looking to consistently solve the m^n case, including conditions where m is negative and n is non-integer. I'd like to, additionally, catch the error when it isn't possible.
Some examples to think about.
(-.5)^(.2) which is, effectively, the fifth root of (-1/2) which has a solution. If I were to simplify the numbers as something like (-1/32)^(1/5) then the answer is clearly -1/2. However, pow(m,n) will not solve that correctly.
Let's be explicit and compare that to the condition like (-.5)^.125, which is the eighth root, since the power is 1/8, and therefore the code would need to throw/catch that as isComplexNumber error.
The thing is, I know I can make an attempt to resolve the fractional equivalency of the number, check the base, and if it's an odd then negative the result of pow(abs(m),n), but due to irregularities in doubles, it's hard sometimes to resolve that decimal exponent into a fraction. What's more that's just inelegant coding.
The other potential solution path I see is to create a for-loop which brute-force solves for the root using guess and check (with some marginal inherent inaccuracy), which is even less attractive.
Thoughts? This has been solved by TI, Mathematica, etc. Am I missing something basic?