Reduce improvement.
Add reduce test
Add average function
Add derivative