0

Have a look at the Mathematica calculation

z = {{1}, {0}};

o = {{0}, {1}};

Ψ = Sin[θ]*KroneckerProduct[z, z, z] + 
Cos[θ]*KroneckerProduct[o, o, o] // MatrixForm

Ψt = 
Transpose[{{Sin[θ]}, {0}, {0}, {0}, {0}, {0}, {0}, {Cos[θ]}}] // MatrixForm

ρ = Ψ.Ψt;

ρ // MatrixForm

After calculation at the last step we shall get a $6\times 6$ matrix ρ. But Mathematica is showing me $$\begin{bmatrix}\sin[\theta] \\ 0\\0\\0\\0\\0\\0\\ \cos[\theta]\end{bmatrix} . \begin{bmatrix} \sin[\theta] & 0 & 0 & 0 & 0 & 0 & 0& \cos[\theta]\end{bmatrix}$$

I like to get the in matrix form for farther calculations. Might be I have done some mistake, that I do not know. What changes to do?

Thank you for your help.

xyz
  • 605
  • 4
  • 38
  • 117
Supriyo
  • 265
  • 1
  • 2
  • 7
  • Welcome to Mathematica.SE! In case you didn't know, you can format your code better by putting four spaces at the front of every code block (or click on the curly-brace button above the question editing area). Further, wrap short inline code snippets in a pair of backticks ``. This will make your post easier to read. –  Nov 09 '14 at 04:03

2 Answers2

1

One problem is you're assigning the matrix form to your variable. Put matrix form on after setting your variable, e.g. MatrixForm[p = mat] not p = mat // MatrixForm.

z = {{1}, {0}};
o = {{0}, {1}};
MatrixForm[
 p = Sin[t]*KroneckerProduct[z, z, z] + 
   Cos[t]*KroneckerProduct[o, o, o]]
MatrixForm[pt = Transpose[p]]
r = p.pt;
r // MatrixForm
Chris Degnen
  • 30,927
  • 2
  • 54
  • 108
1

Since you are comfortable with the Kronecker product, you might also be interested in the command Outer which can be used quite succinctly in this setting:

z = {1, 0};
o = {0, 1};
p = Flatten[Sin[t]*KroneckerProduct[z, z, z] +  Cos[t]*KroneckerProduct[o, o, o]];
mat = Outer[Times, p, p];
MatrixForm[mat]

which gives the desired form.

bill s
  • 68,936
  • 4
  • 101
  • 191