Solved by richard in post #4 
              
              
                If you multiply it by a constant, the gradient computation will include that constant. If you have f(x) and you multiply it by 2, ie, 2 * f(x), differentiating wrt x gives 2 * f'(x). It’s the same thing here. 
If you weight the distances accordingly, then sum them together, the distance with the lar…