Message Boards Message Boards

0
|
2682 Views
|
2 Replies
|
3 Total Likes
View groups...
Share
Share this post:

How can I do NIntegrate of derivative of the function?

Posted 4 years ago
POSTED BY: Sangshin Park
2 Replies
Posted 4 years ago

Aha! Thank you!!

POSTED BY: Sangshin Park

Those ?NumericQ in the definition of f interfere with symbolic computation. Also, if you calculate the derivative with D[f[x, a], x], the variable x will become numerical too soon, before the symbolic derivative is calculated. One way to solve the problem is to use Derivative, which does not use a symbolic variable name:

f[x_, a_] := Sin[a x]
d[x_?NumericQ] := NIntegrate[Derivative[1, 0][f][x, a], {a, 0, 1}]

Another way, which localizes the symbolic variable:

f[x_, a_] := Sin[a x]
d[x_?NumericQ] :=
 Module[{y},
  NIntegrate[D[f[y, a], y] /. y -> x, {a, 0, 1}]]
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract