I need matrix H. G is working, but H is just derivative?? How to obtain?
g = Integrate[x^(p + q - 2*(m + n + 1)), {x, -1, 1}];
h = Integrate[D[x^(p + q - 2*(m + n + 1)), {x, 2}], {x, -1, 1}];
c[r_, n_] := ((-1)^n (2 r - 2 n - 7)!!)/(2^n n! (r - 2 n - 1)!);
G = Table[Sum[c[p, n] c[q, m] (g), {m, 0, (q - 1)/2}, {n, 0, (p - 1)/2}], {p,
5, 12}, {q, 5, 12}];
H = Table[Sum[c[p, n] c[q, m] (h), {m, 0, (q - 1)/2}, {n, 0, (p - 1)/2}], {p,
5, 12}, {q, 5, 12}];
G // MatrixForm
H // MatrixForm
The problem lies with the upper limits on $m$ and $n$ in the definition of $H$. Going back to the integral,
$$\int^{1}_{-1} \frac{d^2}{dx^2} x^{p + q - 2(m + n + 1)} dx$$
which Mathematica returns as
which I've abbreviated for readability. The key is the condition $\Re(-2(m+n) + (p+q))>3$, which is not true for $m = (q - 1)/2$ and $n = (p-1)/2$. So, at that point, the false branch of
Ifis returned.The difficulty is that you're trying to have Mathematica automatically do all the work for you, like in this similar question. When $m = (q - 1)/2$ and $n = (p-1)/2$, $p + q - 2(m + n + 1) = 0$ implying that the derivative should be zero. However, when the derivative was taken, Mathematica had no knowledge of this difficulty, so it gives the wrong result.
I'd do the following:
where
hdoes not require the second condition as it is zero anyway.