Advertisement
MatsGranvik

Powers of matrix A and Eric Naslunds answer

Oct 30th, 2016
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. (*Mathematica start*)
  2. Print["Try changing the power of matrix A here:"]
  3. power = 2
  4. nn = 12;
  5. A = Table[Table[If[Mod[n, k] == 0, k, 0], {k, 1, nn}], {n, 1, nn}];
  6. B = Table[
  7. Table[If[Mod[k, n] == 0, MoebiusMu[n], 0], {k, 1, nn}], {n, 1, nn}];
  8. MatrixForm[MM = MatrixPower[A, power].B];
  9.  
  10. Clear[t, n, k, M, x];
  11. t[n_, 1] = 0;
  12. t[1, k_] = 0;
  13. t[n_, k_] :=
  14. t[n, k] =
  15. If[n < k,
  16. If[And[n > 1, k > 1], x - Sum[t[k - i, n], {i, 1, n - 1}], 0],
  17. If[And[n > 1, k > 1], x - Sum[t[n - i, k], {i, 1, k - 1}], 0]];
  18. M = Table[Table[t[n, k], {k, 1, nn}], {n, 1, nn}];
  19. MatrixForm[M];
  20. Print["The roots of the ", power, "-d powers of the matrix"]
  21. N[(x /. Solve[Det[M + MM] == 0, x] )]
  22. Print["Eric Naslunds formula for the arithmetic sequence"]
  23. N[Table[MoebiusMu[n]^2*n^(power)/(n - EulerPhi[n]), {n, 2, nn}]]
  24. (*Mathematica end*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement