gradient for minus, max, and dot product (still needs work)