Tests if a given expression is algebraic