3
$\begingroup$

I've defined the following two very similar recursive functions:

ET1[n_, x_] := If[n == 0, 0, 
               Integrate[(ET1[n - 1, x]), {z, 0, x}] + 
                Integrate[(y + ET1[n - 1, y]), {y, x, 1}]]

ET2[n_, x_] := If[n == 0, 0,
                Integrate[(ET2[n - 1, x]), {y, 0, x}] +
                 Integrate[(y + ET2[n - 1, y]), {y, x, 1}]]

The only difference is whether the first Integrate uses z or y, and the integrand includes neither of those variables. I don't have any idea why this should affect the result; in either case the integral should come out to x * ET[n-1, x] (the reason I'm not just writing that out in the first place is that I think the integral makes the logic clearer). For n=1 and n=2, the two functions in fact appear to agree for all x between 0 and 1. But on Mathematica 10.4.1, I'm getting that ET1[3,0] = 13/12 while ET2[3,0] = 7/8. For what it's worth, if I replace the first Integrate with what it should evaluate to (i.e. x * ET[n-1, x]), then it gives the same answer as ET1.

What gives?

$\endgroup$
  • $\begingroup$ I took the version 10 tag off, since this happens on other versions as well. $\endgroup$ – Michael E2 Aug 7 '16 at 10:55
3
$\begingroup$

You can do a semi-trace by inactivating Integrate:

Block[{Integrate = Inactive[Integrate]}, ET1[3, 0]]

Mathematica graphics

Block[{Integrate = Inactive[Integrate]}, ET2[3, 0]]

Mathematica graphics

Near the beginning of the second lines, some dy in the first integral are dz in the second. They give different results:

Mathematica graphics

$\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.