vectorise linear term fixup in gradient2