====== Recreate DensityMatrixPlot ====== ;;# asked by [[mailto:dwt2004@gmail.com|David Tam]] (2022/03/27 19:10) ;;# == == In Mathematica, I define the basis according to the documentation for DensityMatrixPlot: lbasisF =   With[{l = 3},    Flatten[Table[{SphericalHarmonicY[l, m, \[Theta], \[Phi]],       SphericalHarmonicY[l, m, \[Theta], \[Phi]]}, {m, -l, l}]]]; Now I can construct a density matrix with some randomly chosen numbers, and make a plot: dmF = CFDensityMatrix[3, 1,   With[{vv = {0.7, 0, 0.3, 0, 0, 0.3, 0, 0, 0.1, 0.5, 0.1, 0, 0.2, 0}}, vv/Sqrt@Total[vv^2]]] DensityMatrixPlot[dmF] However, the following superposition shows that directly plotting in the orbital basis doesn't make the same plot: Show[  dmplot,  SphericalPlot3D[ Conjugate[lbasisF].dmF.lbasisF, {\[Theta], 0, Pi}, {\[Phi], 0,(*2 Pi*)Pi}   , PlotRange -> All, AspectRatio -> Automatic, AxesLabel -> {"x", "y", "z"}]  ] What is the right way to find the angular function as function of theta and phi, and how does DensityMatrixPlot avoid this problem? ~~DISCUSSION|Answers~~