Added file for calculating gradient. Designed for Sebastian's study.