1
$\begingroup$

I have a table of integrals that I want to put in an nxn matrix. I tried doing it in the following way

phix[x_, n_] := Exp[-n \[Alpha] x^2/2]
phiy[y_, m_] := Exp[-m \[Beta] y^2/2]
const = {List[
    Integrate[
     x^2 y^2 phix[x, n1] phix[x, n2] phiy[y, m1] phiy[y, m2], {x, 0, 
      Infinity}, {y, 0, Infinity}], {n1, 1, 3}, {n2, 1, 3}, {m1, 1, 
     3}, {m2, 1, 3}]} // MatrixForm

but what I get as output is the following, instead of the matrix form. output

I also tried to use Table instead of list, but still don't get the output in the matrix form. I need the output as a matrix because I would like to calculate the e-values and e-vectors.

Any help would be greatly appreciated.

$\endgroup$
1
  • $\begingroup$ @AntonAntonov, I have added the definitions of the functions in the questions above. They are just Gaussians that are integrated. $\endgroup$
    – Christian
    Oct 10 '20 at 14:51
2
$\begingroup$

You probably want to use the option Assumptions.

Some coding suggestions:

  • consider making the matrix of integrals first keeping phix and phiy undefined, and

  • then provide definitions through Block or ReplaceAll.

Here is an example:

Clear[const, phix, phiy]

const = Table[
   Integrate[
    x^2 y^2 phix[x, n1] phix[x, n2] phiy[y, m1] phiy[y, m2], {x, 0, 
     Infinity}, {y, 0, Infinity}, 
    Assumptions -> {\[Alpha] > 0, \[Beta] > 0}], {n1, 1, 3}, {n2, 1, 
    3}, {m1, 1, 3}, {m2, 1, 3}];
Magnify[MatrixForm[const], 0.6]

Block[{phix, phiy},
 phix[x_, n_] := Exp[-n \[Alpha] x^2/2];
 phiy[y_, m_] := Exp[-m \[Beta] y^2/2];
 MatrixForm[const]
]

enter image description here

Magnify[MatrixForm[const], 0.6] /. {phix[u_, v_] :> 1/(v + u)^3, 
  phiy[u_, v_] :> 1/(u + v)^3}

enter image description here

$\endgroup$
4
  • $\begingroup$ Thank you for your answer. I did have assumptions in my code. Just didn't post them here. I also did get the first output that you posted, but when I try to get the eigenvalues it does not work. It seems like mathematical does not recognize that as a matrix so that I can take eigenvalues. Also, I am confused by the second definition and output you have above. $\endgroup$
    – Christian
    Oct 10 '20 at 15:08
  • $\begingroup$ "I also did get the first output that you posted, but when I try to get the eigenvalues it does not work." -- well, please, complete your question post with the actual code and difficulties you have. $\endgroup$ Oct 10 '20 at 15:12
  • 3
    $\begingroup$ If you say: const= ... // MatrixForm, Then const will look like: MatrixForm[...] what is not suited for further calculations. What can do, e.g.:(const= ...) // MatrixForm $\endgroup$ Oct 10 '20 at 17:14
  • $\begingroup$ @DanielHuber Yeah, good point. $\endgroup$ Oct 10 '20 at 17:31

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.