I need to take the derivative of a function that have a numerical integration on it. The variable in which the integration will be taken is not the same as the one in which the derivative will be taken, so I can take the derivative before integrating the expression. I have tried the following:
nfun[x1_?NumericQ, x2_?NumericQ] := NIntegrate[Cos[x1^x/x2], {x, 2, 3}]
tvar = {x1 -> 0.1, x2 -> 0.3};
D[nfun[x1, x2], x1] /. tvar
And it worked pretty fine. But my real expression has multiple variables and multiple numerical integrations, so I would like to take a list of arguments as input. I also have to take one derivative for each variable. So I tried the following:
nfun1[arg : {_?NumericQ ..}] := NIntegrate[Cos[#1^x/#2], {x, 2, 3}] & @@ arg
But when I try:
D[nfun1[x1, x2], x1] /. tvar
It doesn't work...
I have tried what is proposed in here: Derivative after numerical Integration (2nd answer), but I couldn't get it to work Do you have any sugestions?
I hope I could express myself correctly
Edit: As Mark and Myke showed, the syntax in the second try is wrong, it should be:
D[nfun1[{x1, x2}], x1] /. tvar
But still not working :(
nfun1[arg : _?NumericQ ..] := NIntegrate[Cos[#1^x/#2], {x, 2, 3}] &@arg; D[nfun1[x1, x2], x1] /. tvar
. Does that work? $\endgroup$