Replacement for @raoulb pr#914

See #914

ToDo:
- [x] tests
- [x] final rebase
> tan or cot? Naive application of the general formula would result in tan, no?

No.  It's cot.

> Could use self.func here as in the tan case.

Sure.