# Issue with definite integration by parts using IntegrateByParts

I am trying to prove Cauchy's identity with Mathematica ResourceFunction["IntegrateByParts"]. It doesn't seem to work with definite integration. Cauchy's identity says: $$\int_{a}^{x}dz\int_{a}^{z}dy f(y)=\int_{a}^{x} (x-y)f(y)dy$$ To prove Cauchy's identity I introduce a function F[z_] -> Inactive[Integrate][f[y], {y, a, z}]. Then, using IntegrateByParts on F[z], and applying the substitution rule F'[z] -> f[z] yields:

ResourceFunction["IntegrateByParts"][ F[z], {z, a, x}];
% /. {F[z_] -> Inactive[Integrate][f[y], {y, a, z}]};
% /. F'[z_] -> f[z] // Activate


This is not the expected result from Cauchy's identity. How can the IntegrationByParts be modified to work and verify Cauchy's identity?

I think it's a bug of ResourceFunction["IntegrateByParts"]. The output of

ResourceFunction["IntegrateByParts"][F[z], {z, a, x}]


is

-F[a] + F[x] - Inactive[Integrate][z Derivative[1][F][z], {z, a, x}]


but clearly the correct output should be

-a F[a] + x F[x] - Inactive[Integrate][z Derivative[1][F][z], {z, a, x}]


By checking the source code (it can be found by DirectoryName@FindFile@"ResourceFunctionHelpers" <> "\\IntegrateByPart.wl" // SystemOpen, at least on Windows 10), there seems to be a mistake in the definition of makeResult. The

Subtract@@(f /. {{x -> hi}, {x -> lo}})


should be modified to

Subtract@@(u v /. {{x -> hi}, {x -> lo}})


With this correction, your code will give the desired result. BTW the code can be simplified to

ResourceFunction["IntegrateByParts"][F[z], {z, a, x}]
% /. F -> Function[z, Inactive[Integrate][f[y], {y, a, z}]]
% // Activate

• Thanks! This looks good. But I can't check the source code, I get $Failed when running DirectoryName@FindFile@"ResourceFunctionHelpers" <> "\\IntegrateByPart.wl" // SystemOpen. Am I missing something? Jul 15, 2020 at 10:32 • @Ferca Which system are you in? Does $UserBasePacletsDirectory <> "\\Repository\\ResourceFunctionHelpers-1.3.1\\Kernel\\IntegrateByPart.wl" // SystemOpen work? Can you find a IntegrateByPart.wl file under $UserBasePacletsDirectory? Jul 15, 2020 at 10:43 • I am running a Mathematica (V 12.1.1.0) notebook in a Mac OS X x86. The filenames I get after running $UserBasePacletsDirectory are {"Configuration", "Repository", "Temporary"}. The command $UserBasePacletsDirectory <> "\\Repository\\ResourceFunctionHelpers-1.3.1\\Kernel\\\ IntegrateByPart.wl" // SystemOpenalso gives me $Failed Jul 15, 2020 at 10:55
• @Ferca I'm on Windows 10 so can't test, but can you visit the directory outside of Mathematica? Jul 15, 2020 at 11:03
• @Ferca The directory is hidden on Windows, I guess it's similar on Mac OS X. Jul 15, 2020 at 11:27