I tried to make it clear what the function is capable of; it now does everything it did before and more. I'm not sure that it should be able to identify the domain boundaries, e.g that x > 0 for log(x) or x >=0 for sqrt(x). In the former case x=0 can be returned; what would be returned in the latter case (and is that, perhaps, a different functionality)?