An example of the output of your program for derivative: If the original matrix is: 7 2 2 5 5 8 8 1 1 4 8 4 1 8 0 0 9 8 6 2 3 1 5 3 1 Then the derivative with respect to x should be: -10 -17 -1 9 3 -9 -26 -7 8 -2 1 -13 -2 -5 -17 12 11 0 -17 -18 5 12 1 -14 -8 The derivative with respect to y should be: 8 12 0 -10 -6 4 4 3 0 -7 -15 1 20 15 1 -13 -7 0 -5 -3 -2 -16 -17 -10 -5 I'll go over this particular example in class. For boundary cases, things are a bit trickier than applying the formula in the specification. In some cases, you ignore an entire term, in other cases you treat one value as being the value that isn't off the array. Let's consider dX only for now (since dY is the same idea) There are two kinds of edge cases. 1)Edge cases where just one element is missing 2)Edge cases where the entire group is missing. Number 1 occurs when you try to compute the middle term 2 * (m[i][j+1] - m[i][j-1]) at a spot such as 0,0. This is since the index [0,1] is fine, as is [0,0], but [0,-1] is not. In this case, you should just use the value at [0,0] Number 2 occurs when the entire row is missing. This happens to the term (m[i-1][j] - m[i-1][j-1] ) for the value [0,0] since the whole row is no good [-1,-1], [-1,0], and [-1,1] are all invalid. So in the case of the example, the terms to add are 2 * (m[i][j+1] - m[i][j]) + (m[i+1][j+1] - m[i+1][j] ) = 2 * (-5) + 0 Please email me or come to my office hours if you are trouble.