Search code examples
maxima

How to determine if a variable is exponential in maxima?


I want to determine in an expression as 2^n or n^2 or 2*n if the variable $n$ is exponential. So in those cases only the first one would return true.

Any ideas?


Solution

  • The easy answer is to use freeof:

    (%i1) exponentp(e,n):=not mapatom(e) and 
                          op(e) = "^" and not freeof(n,second(args(e)))$
    

    Then:

    (%i2) map(exponentp,[2*n,n^2,2^n,(n+1)^(a+b), (a+b)^(n+c),2^(3/n+1)],[n,n,n,n,n,n]);
    
    (%o2) [false,false,true,false,true,true]
    

    Which is the desired answer, I believe.