Update functions.R

gradient/n