The `operate` method is very complex. I wonder if these nested blocks for `sqrt`, `sin` and so on could be extracted into their own methods to keep things concise