https://trac.pythonprogramminghelp.com/the-best-the-gradient-vector-ive-ever-gotten/