0
$\begingroup$

I am trying to define a derivative of a function which is itself an integral. The function GaussInt[f_,x_] is the integral over f (a function of x) with respect to the measure $\exp(-x^2/2)/\sqrt{2\pi}$. I prefer to use the function GaussInt rather than write out the integral to prevent mathematica from attempting to solve the integral (which it can't do, but it spends a lot of time trying). The problem is that GaussInt doesn't satisfy the usual chain rule. That is

D[GaussInt[f_,x_], z_]:= GaussInt[D[f,z], z]

but Mathematica uses the chain rule to decide

D[GaussInt[f_,x_], z_] := GaussInt'[f,x] D[f,z]

which usually leads to the wrong answer.

I can get around this by defining my own differentiation operator

Dd[GaussInt[a_,z_],x_] := GaussInt[Dd[a,x], z]

I then have to define all the usual rules for Dd. Although this works its is rather inelegant. My problem is I don't know how to robustly switch off the chain rule for differentiation when applied to my function GaussInt . Any ideas?

$\endgroup$
  • $\begingroup$ What exactly is the input and output when you ask for the derivative of GaussInt? Are you doing D[GaussInt[f,x],x]? Because this evaluates to Derivative[0, 1][GaussInt][f, x] (which displays as $\mathrm{GaussInt}^{(0,1)}[f,x]$), not GaussInt'[f,x] (the latter doesn't make sense, as prime is only used for a single-variable function). $\endgroup$ – jjc385 Sep 8 '17 at 16:16
  • $\begingroup$ Note that it would be better for you to post the actual input or output rather than putting them in a := form (unless, of course, your input was in the form of a := statement). $\endgroup$ – jjc385 Sep 8 '17 at 16:19
1
$\begingroup$

You could use Inactive :

Inactive[Integrate][f[x] Exp[-x^2/2]/Sqrt[2 π], x]

which leaves the integral unevaluated (and formats the output as an integral). Then it plays nicely with derivatives:

D[%, x]

Evaluation screenshot

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.