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
    Doesn't work again h?2011-11-04
  • 0
    @George, looking at the terms in `H` for all $p=q$ between $5$ and $12$, they add identically to zero. For a lot of the other values of $p$ and $q$, all of the terms are identically equal to zero.2011-11-04
  • 0
    Why it is problem again with matrix H? It should be diagonal, not all elements zero???2011-11-04
  • 0
    The problem is the same and matrix G=X1 but matrix H is not equal with Y1. Y1 is right answer, but how to get it following your instructions? f[r_] := Sum[(((-1)^n*(2*r - 2*n - 7)!!)/(2^n*n!*(r-2*n - 1)!))* x^(r - 2*n - 1), {n, 0, r/2}]; Nw := Transpose[Table[f[j], {i, 1}, {j, 5, 12, 1}]]; X1 = Integrate[Nw.Transpose[Nw], {x, -1, 1}]; Y1 = Integrate[D[Nw, {x, 2}].Transpose[D[Nw, {x, 2}]], {x, -1, 1}]; MatrixForm[X1] MatrixForm[Y1]2011-11-04
  • 0
    @George, give me several hours to get back to this. I'll take a look at it then.2011-11-04
  • 0
    Ok! Thank you. The right answer should be Y1=H, diagonal.2011-11-04
  • 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