There is a simple method for working out the gradient of a straight line joining any two points, for which the X and Y coordinates are known. For instance, if our first point is: A(X1,Y1), and our second point B(X2, Y2) then the gradient we are looking for is the gradient of the straight line AB, which joins the two points. This value is the difference in the Y coordinates, divided by the difference in the X coordinates, given by the equation: (Y2 - Y1) / (X2 - X1).
So, if the points are A(5, 2) and B(10, 4), then the gradient of the line AB would be: (4 - 2) / (10 - 5) = 2 / 5 = 0.4