Search code examples
mathematical-optimizationderivativecalculus

Taking derivative of a function


I have function and need to take partial derivatives respect to its two variables.

The function is:

sum over r, p, q

Since I am not really good at math, I need some help to know the following derivatives:

df/dp and df/dq


Solution

  • Let F(p,q) be

    F(p,q) = sum(j, [ r(j) - sum(i, p(i,j)*q(i,j)) ]^2 )
    

    Then dF/dp is the matrix A formed by elements

    A(i,j) = 2 * [r(j) - sum(k, p(k,j)*q(k,j))] * (-q(i,j))
    

    dF/dq is the matrix B formed by elements

    B(i,j) = 2 * [r(j) - sum(k, p(k,j)*q(k,j))] * (-p(i,j))