0
$\begingroup$

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 
  • 0
    Can you do me a favor and give some details as to the mathematics problem you're trying to solve? If we can understand what it is you're trying to accomplish, we may be able to provide better answers.2011-11-16

1 Answers 1

2

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

(-1 - 2 (1 + m + n) + p + q) (-2 (1 + m + n) + p + q)  * If[ Re[-2 m - 2 n + p + q] > 3,        ... ,        Integrate[x^(-2 - 2 (1 + m + n) + p + q), {x, -1, 1},          Assumptions -> Re[-2 m - 2 n + p + q] <= 3]   ] 

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 If is 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:

g = Piecewise[{      {Integrate[x^(p + q - 2*(m + n + 1)), {x, -1, 1},         Assumptions -> (-2 (m - n) + p + q) > 1],        -2 (m - n) + p + q > 1},     {2,  -2 m - 2 n + p + q == 1}}]  h = Piecewise[{      {Integrate[D[x^(p + q - 2*(m + n + 1)),{x,2}], {x, -1, 1},         Assumptions -> (-2 (m - n) + p + q) > 3],        -2 (m - n) + p + q > 3} }] 

where h does not require the second condition as it is zero anyway.

  • 0
    @George, my apologies for not getting back to you sooner. I have a couple of questions. Why should $H$ be diagonal? I don't see any reason, _a priori_, why it should be. So, I'd check to see that `c[n,m]`, `h`, and `g` are giving you what you expect. If not, let me know what you expect them to be, and we'll see if we can get them there.2011-11-08