Impose domain restrictions in trig substitution

Imposes appropriate domain restrictions when making trig substitutions so tests pass. I have manually forced the simplification (`sqrt(cos(x)**2) == cos(x)`, assuming `cos(x) > 0`) using substitutions.