# Select base and exponent of arbitrary number

I want to write a function say BaseExponent that will output the base and exponent of a number. In particular it should do the following:

BaseExponent[(1 + I Sqrt)^(1/72)] = {(1 + I Sqrt), 1/72}
BaseExponent = {72, 1}
BaseExponent[1/4] = {1/4, 1}
BaseExponent[Sqrt[-3]] = {-3, 1/2}
BaseExponent[I Sqrt] = {-3, 1/2}
BaseExponent[(3/4)^(1/4)] = {3/4, 1/4}


I started by doing the following:

BaseExponent[a_] /; (! FreeQ[a, Power]) := {a[], a[]}
BaseExponent[a_Integer] := {a, 1}
BaseExponent[a_Rational] := {a, 1}


What I have supplied takes care of the first three examples but definitely not rest. Any ideas on how to extend this to cover all the cases I have provided in the example above?

• You need to give a complete and consistent specification for what constitutes a base, what constitutes an exponent, and what constitutes an admissible expression. For example, if I Sqrt is to give {-3, 1/2}, does it follow that 2 Sqrt is to give {12, 1/2}? Further, what you to get from expressions such as Surd[12, 2] and CubeRoot? – m_goldberg Nov 6 '15 at 21:35

This should get you closer

BaseExponent[
a_. Power[b_, e_]] := ({a^(1/e) b,
e} /.
{a2_. Power[b2_, e2_], e3_} :> {a2^(1/e2) b2, e3*e2})
BaseExponent[a_Integer] := {a, 1}
BaseExponent[a_Rational] := {a, 1}

BaseExponent[a_. Complex[r_, i_]] :=
{a Complex[r, i], 1} (*  EDIT: added per evansdoe comment  *)

And @@ {
BaseExponent[(1 + I Sqrt)^(1/72)] ===
{(1 + I Sqrt), 1/72},
BaseExponent === {72, 1},
BaseExponent[1/4] === {1/4, 1},
BaseExponent[Sqrt[-3]] === {-3, 1/2},
BaseExponent[I Sqrt] === {-3, 1/2},
BaseExponent[(3/4)^(1/4)] === {3/4, 1/4},
BaseExponent[Surd[12, 2]] === {12, 1/2},
BaseExponent[CubeRoot] === {12, 1/3},
BaseExponent[a Complex[r, i]] === {a Complex[r, i], 1}}

(*  True  *)

• Thanks but this case BaseExponent[(1 + I Sqrt)]  that is complex numbers (a + I b) with exponents as 1 was not considered. I forgot to include this case in my question. I will figure it out and post the answer later. However anyone is also welcome to give it a try. – saintdoe Nov 8 '15 at 13:33
• With BaseExponent[ a_.Complex[r_, i_]] := {Complex[r, i], 1} we have BaseExponent[(1 + I Sqrt)] = {1 + I Sqrt, 1} – saintdoe Nov 8 '15 at 14:53
• @evansdoe - added additional case. Note your comment left out factor of a on RHS of definition. – Bob Hanlon Nov 8 '15 at 15:50