Derivative over double summation?
Mostrar comentarios más antiguos
Please, can someone help me find the derivatives in this attachment? You can solve it in the attached excel document or solve it in word document and post the snap shot of the solution. Thank you so much.

4 comentarios
David Goodmanson
el 13 de En. de 2019
Hi Samuel,
Since m_ij is an object with two indices, what is the meaning of m_k in the expression dP/dm_k?
SAMUEL AYINDE
el 13 de En. de 2019
David Goodmanson
el 13 de En. de 2019
Hi Samuel,
so by dP/dm do you mean a matrix whose ij component is dP/dm_ij?
Also the summand in each of the double sums defining P is identical, so the two double sums are almost identical, differing only in slight chages in the upper limits. Is this what is intended?
SAMUEL AYINDE
el 13 de En. de 2019
Respuestas (1)
Walter Roberson
el 13 de En. de 2019
0 votos
The derivative of absolute value is not well defined.
8 comentarios
Walter Roberson
el 13 de En. de 2019
Editada: Walter Roberson
el 13 de En. de 2019
Derivative implies that the m values are varying continuously. However, I recognize the structure of what is being computed, and the m values are not varying continuously, they are discretized because the inputs are intended to be pixel intensities.
If you want to treat the m entries as-if they are continuous, then you need to recognize that different m entries need to be considered independent variables, so dP/dm would need to be understood as a Jacobian rather than a single value.
m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j)
take the derivative with respect to the variable m(i,j) and you get
diff(m(i,j) * rho(i,j), m(i,j)) - diff(m(i+1,j) * rho(i+1,j), m(i,j))
which would be
rho(i,j) - diff(m(i+1,j), m(i,j)) * rho(i+1,j)
which would be
rho(i,j) - 0 * rho(i+1,j)
because m(i+1,j) is an independent variable compared to m(i,j)
and differentiating with respect to m(i+1,j) would give -rho(i+1,j) and differentiating with respect to any other m(p,q) would give 0. As a first pass then the double sum would involve sum() of a subset of rho minus sum of a slightly different range of rho, which would would revolve down to the difference of the two boundary conditions. (Hmmm, this might need to be revisited.)
But you are using abs() of the difference rather than the plain difference. The derivative of abs(a*b,a) is b*sign(a) provided that a is real and non-zero. In the case of abs(m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j)) then with m very likely representing pixel values in context, then unless rho is nonlinear and min(diff(unique(rho(:)) is greater than max(diff(unique(m(:)))) so that the rho "projects" the m values into separate spaces, then it is likely that m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j) will come out as 0 at some points, and then the derivative of the absolute value is undefined.
Under the assumption that is probably unjustifiable that m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j) can never be exactly 0, then the derivative of abs(m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j)) with respect to m(i,j) would be rho(i,j) * sign(m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j)) and the derivative with respect to m(i+1,j) would be -rho(i,j)*sign(m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j))
Hmmm, for any given K,L pair, m(K,L) appears once when i=K, j=L in the first term, giving rho(K,L)*sign(m(K,L) * rho(K,L) - m(K+1,L)*rho(K+1,L)), and appears once when i=K-1, j=L in the second term giving -rho(K,L)*sign(m(K-1,L) * rho(K-1,L) - m(K,L) * rho(K,L)) . The sum of those two would be the derivative with respect to m(K,L) except for the boundary condition. So that would be rho(K,L) * (sign(m(K,L) * rho(K,L) - m(K+1,L)*rho(K+1,L)) - sign(m(K-1,L) * rho(K-1,L) - m(K,L) *rho(K,L))) . This appears to be something that could be calculated in vectorized form except perhaps for the boundary conditions.
However, I would be surprised if m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j) can never equal 0, so I do not think the derivative of abs(m(i,j) * rho(i,j) - m(i+1,j) * rho(i+1,j)) would be well defined.
Walter Roberson
el 13 de En. de 2019
I see your revision that gives an approximation for absolute value, but the approximation you post is not differentiable at 0.
diff(sqrt((1 + 2*e)*x^2) - e, x);
(1 + 2 e) x
-------------------
(1/2)
/ 2\
\(1 + 2 e) x /
limit(%, x = 0);
undefined
SAMUEL AYINDE
el 13 de En. de 2019
SAMUEL AYINDE
el 13 de En. de 2019
Walter Roberson
el 13 de En. de 2019
"Picture or it didn't happen" ?

Your absolute value approximation is not useful.
Perhaps you mean sqrt(x^2 + 2*e) - e ? The limit of the derivative of that as x approaches 0 is 0. The value of the function itself as x approaches 0 is sqrt(e)*sqrt(2).
Walter Roberson
el 13 de En. de 2019
dP/dm_i is 0 because m_i does not exist in the equations. You have m_ij but not m_i .
If you are trying to imply derivative with respect to an entire row of m, then that is still with respect to a vector of variables rather than a single variable.
The analysis I gave above reached
rho(K,L) * (sign(m(K,L) * rho(K,L) - m(K+1,L)*rho(K+1,L)) - sign(m(K-1,L) * rho(K-1,L) - m(K,L) *rho(K,L)))
sign(0) is defined as 0, same as the approximation reached by sqrt(x^2 + 2*e) - e in the limit of e approaches 0, so you could substitute sign() provided that if you write this up as a formal analysis that you demonstrate that you considered the differentiability and substituted sqrt(x^2 + 2*e) - e and then took the limit as e approaches 0 get sign().
SAMUEL AYINDE
el 14 de En. de 2019
Editada: SAMUEL AYINDE
el 14 de En. de 2019
Walter Roberson
el 14 de En. de 2019
The solution is as I gave before with the difference of sign() , but remember you need to be careful on the boundary condition .
The derivative is 0 except for at most two terms because the m variable are independent except the two cases of identical subscripts. So you can break it down to three cases, one for each of the two boundary conditions and one for the centre. You can then vectorize for the centre and vectorize for each of the two boundary conditions . or perhaps it works out to be four boundary conditions . Small number of them anyhow .
Categorías
Más información sobre App Building en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
