Guest User

Untitled

a guest
Dec 12th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. Pdf1= 2 Sqrt[2/[Pi]] (x1-x2) exp(1/2 (-x1 (3 x1-x2)-x2 (3 x2-x1)))
  2.  
  3. rg= {{x1, -Infinity, Infinity}, {x2, -Infinity, x1}};
  4. ContourPlot[Pdf1, Sequence @@ rgn // Evaluate, ImageSize -> Small]
  5.  
  6. Clear[int]; int[a_, b_] :=
  7. Integrate[ a b Pdf1, Sequence @@ rg // Evaluate]
  8.  
  9. Clear[nint]; nint[a_, b_] :=
  10. NIntegrate[ a b Pdf1, Sequence @@ rg // Evaluate]
  11.  
  12. p = 2; pol0 =
  13. Table[Table[x1^i x2^(p1 - i), {i, 0, p1}] // Flatten // Union,
  14. {p1, 0, p}] // Flatten // Join
  15.  
  16. pol = Orthogonalize[pol0, int[#1, #2] &]
  17.  
  18. Map[ContourPlot[# Pdf1 , Sequence @@ rgn // Evaluate,
  19. PlotPoints -> 15, PlotRange -> All] &, pol]
  20.  
  21. pol = Orthogonalize[pol0, intn[#1, #2] &, Method -> "Reorthogonalization"];
  22.  
  23. p = 6; pol0 =
  24. Table[Table[x1^i x2^(p1 - i), {i, 0, p1}] // Flatten // Union,
  25. {p1, 0, p}] // Flatten // Join;
  26. pol = Orthogonalize[pol0, intn[#1, #2] &, Method -> "Reorthogonalization"];
  27.  
  28. gs[vecs_, ip___] := Module[{ovecs = vecs},
  29. Do[ovecs[[i]] -= Projection[ovecs[[i]], ovecs[[j]], ip], {i, 2,
  30. Length[vecs]}, {j, 1, i - 1}]; ovecs];
  31. pol1 = gs[pol0, Function[
  32. NIntegrate[ ## Pdf1, Sequence @@ rg // Evaluate]]];
  33.  
  34. mat = ParallelTable[int[i, j], {i, pol0}, {j, pol0}];
  35. eigs = Eigensystem[mat // N];
  36.  
  37. Map[ContourPlot[# Pdf1, Sequence @@ rgn // Evaluate,
  38. PlotPoints -> 15, PlotRange -> All] &,
  39. pol = eigs[[2]].pol0/Sqrt[eigs[[1]]] // Chop]
Add Comment
Please, Sign In to add comment