4
$\begingroup$

Define

f[x_, i_] := Piecewise[{{1/n, 
0 < x < (i - 1)/n}, {(i/n - x), (i - 1)/n < x < i/n} , {0, 
i/n < x}} ];

I would like to compute

Integrate[f[x,i]*f[y,i]*f[x,j]*f[y,j],{x,0,1},{y,0,1}],

assuming that $n$, $i$ and $j$ are natural numbers and $1\leq j\leq i\leq n$. So far, I have try to use PiecewiseExpand[f[x,i]*f[y,i]*f[x,j]*f[y,j]] and split the integral in different ways. However, it takes forever the computation of the double integral. Do you have any advice to proceed?

$\endgroup$
5
  • $\begingroup$ Welcome to Mathematica.SE! 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$
    – user9660
    Commented Nov 2, 2015 at 16:43
  • $\begingroup$ Your problem is that you define a function of just $x$ and $i$ that somehow depends upon $n$. $\endgroup$ Commented Nov 2, 2015 at 18:49
  • $\begingroup$ @DavidG.Stork shouldn't it just treat the n as constant and go about the integration as in Integrate[Piecewise[{{ x, 0 <= x < a}, {a, x >= a}}],x]? $\endgroup$
    – IPoiler
    Commented Nov 2, 2015 at 19:21
  • $\begingroup$ Which I now notice returns an incorrect result. $\endgroup$
    – IPoiler
    Commented Nov 2, 2015 at 19:22
  • $\begingroup$ @DavidG.Stork I tried defining instead f[x_, i_,n_] := Piecewise[{{1/n, 0 < x < (i - 1)/n}, {(i/n - x), (i - 1)/n < x < i/n} , {0, i/n < x}} ]; but it did not shown any improvement. $\endgroup$
    – Me-me
    Commented Nov 3, 2015 at 16:17

1 Answer 1

4
$\begingroup$

The answer is:

res[j_, j_, n_] := (3 j - 2)^2 /(9 n^6)  /; j <= n
res[j_, i_, n_] := (2 j - 1)^2 /(4 n^6)  /; j <= i <= n

Testing against your function:

rr[j1_, i1_, n1_] := Block[{j = j1, i = i1, n = n1}, 
                      Integrate[f[x, i]*f[y, i]*f[x, j]*f[y, j], {x, 0, 1}, {y, 0, 1}]]

list = Sort /@ RandomInteger[{1, 10^2}, {100, 3}];
rr @@@ list == res @@@ list
(* True *)

But please don't ask me how I came to know it :)

ArrayPlot[ ] for n == 4

Mathematica graphics

$\endgroup$
1
  • $\begingroup$ Thank you! This actually solves the question as I formulated it. The true is that I also would like to compute Integrate[f[w,i]*f[x,i]*f[x,j]*f[y,j]*f[y,k]*f[w,k],{w,0,1},{x,0,1},{y,0,1}], and so on. But I am afraid I should do some math on paper and latter ask mathematica. $\endgroup$
    – Me-me
    Commented Nov 3, 2015 at 16:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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