gradient not working out as intended

wasting too much time on this