Second Order Partial Derivative

The way you will implement derivatives in code will be similar no matter what language you use. The thing to remember is the definition of a derivative. dy/dx = lim h-> 0 ( ( f( x + h ) + f(x) ) / h ). Now with a discrete data set we can't take h to zero.

Say we have an array of int y[] = [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]. To take the derivative you'll need to set h to either 1 or - 1, assuming the dx from one index to the next is 1 unit. This equates to bringing the limit of h->0 in from either the right or the left. This means there's two ways to take the derivative.

h = 1 1) X' = ( x[n-1] + x[n] ) / 1 Or 2) X' = ( x[n+1] + x[n] ) / 1

To do the partial derivative of a matrix. Go row by row and the column by column and add the two results together.

/r/C_Programming Thread