Approximate derivative of matrix with respect to X
This method will approximate the “derivative” of the matrix with respect to x. What this means, is as the matrix indices moves from left to right, how do the values of the matrix change?
We can approximate this by creating a new matrix based off of m where the value of the new matrix m′ is computed using the following formula:
m′[i][j] = (m[i−1][j +1]−m[i−1][j −1])+2∗(m[i][j +1]−m[i][j −1])+(m[i+1][j +1]−m[i+1][j −1]
Note that in cases on the edge, such as when i = 0 for example, you should treat the value at the location as being the same as the one that was not off the matrix. For example, if the formula says to take m[-1], you should use the value for m instead.
The header should look something like this:
public static int approximateDerivativeX(int m)