'This tests whether a given expression is algebraic or not, in the
given symbols, syms. When syms is not given, all free symbols
will be used. The rational function does not have to be in expanded
or in any kind of canonical form.
This function returns False for expressions that are "algebraic
expressions" with symbolic exponents. This is a simple extension to the
is_rational_function, including rational exponentiation.
Examples
>>> from sympy import Symbol, sqrt
>>> x = Symbol(\'x\', real=True)
>>> sqrt(1 + x).is_rational_function()
False
>>> sqrt(1 + x).is_algebraic_expr()
True
This function does not attempt any nontrivial simplifications that may
result in an expression that does not appear to be an algebraic
expression to become one.
>>> from sympy import exp, factor
>>> a = sqrt(exp(x)**2 + 2*exp(x) + 1)/(exp(x) + 1)
>>> a.is_algebraic_expr(x)
False
>>> factor(a).is_algebraic_expr()
True
See Also
is_rational_function()
References
- http://en.wikipedia.org/wiki/Algebraic_expression'

def is_algebraic_expr(self, *syms):

    if syms:
        syms = set(map(sympify, syms))
    else:
        syms = self.free_symbols
    if (syms.intersection(self.free_symbols) == set([])):
        return True
    else:
        return self._eval_is_algebraic_expr(syms)
