[WIP] Derivative class

TODO:

* [ ] Test this more
* [ ] add Python wrappers