maple

Extract all roots from a numerical expression


I need to extract all roots (including complex I if it's there) from a numerical expression. I'm interested at least in the case when there are no nested roots. For example, if

f:=(3^(2/3)*2^(3/5)+3*I)/(4*2^(2/5)-2*sqrt(5)/7);

then the answer should be this:

A:={I,2^(2/5),2^(3/5),3^(2/3),5^(1/2)};

Or better, just base roots (it's not hard to get B from A though):

B:={I,2^(1/5),3^(1/3),5^(1/2)};

I've had a similar question here, but I could use indets for that. But with numerical expressions indets doesn't help.

One way I could think of is to use op, but there can be quite sophisticated expressions (like many nested fractions, terms, multipliers, etc.). Maybe Maple already has some function that gives all the entries in one list or set?


Solution

  • Here is one way to accomplish that:

    f := (3^(2/3)*2^(3/5)+3*I)
         /(4*2^(2/5)-2*sqrt(5)/7):
    
    indets(f, radical)
      union {ifelse(has(f,I),I,NULL)};
    
              /    (2/5)   (3/5)   (2/3)   (1/2)\ 
             { I, 2     , 2     , 3     , 5      }
              \                                 / 
    

    [edit] By the way, you claimed that you could not utilize indets here, making this quite different from an earlier Question by you.

    But, as shown above, you can utilize indets (except for the I part), as shown above. You could also utilize indets with a refinement/generalization of the type used in my answer to your earlier Question. That is, you can compare these two, for this particular followup example,

    indets(f, `^`(anything,
                  And(positive,rational)));
    
    indets(f, radical);
    

    Also, for your B,

    f:=(3^(2/3)*2^(3/5)+3*I)/(4*2^(2/5)-2*sqrt(5)/7):
    A := indets(f,`^`(anything,
                      And(positive,rational))):
    
    subsindets(A,
               `^`(anything,And(positive,
                     rational)),
               u->op(1,u)^(1/denom(op(2,u))));
    
                    / (1/5)   (1/3)   (1/2)\ 
                   { 2     , 3     , 5      }
                    \                      /