To clarify: the Risch algorithm only knows how to integrate the exponential `exp`.  Every other exponential (exponential meaning `a**b` with `b` dependent on `x`) is converted to `exp` via `a**b = exp(b*log(a))` before integrating, and then converted back via `backsubs`.  So `x**y` is just integrated as `exp(y*log(x))`.   

Removing this line, we get the same result, meaning that apparently Piecewise solves for conditions, which I did not know (I would have expected `log(x) == 0` as the condition, but it still gives `x == 1`.  I guess it does this at the subs stage. Is this why you use subs instead of just putting `qd.as_expr().subs(s)` in directly? I'm not a fan of this contradictory behavior, but we can fix that in another PR.  Though if we do plan to fix it, it would be cleaner to remove the `aa = Dummy('a')` part now.