Advertisement
MatsGranvik

Divisor transform

Dec 30th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. Clear[t, n, k, i, nn, x];
  2. x = -2; (*x=1 gives this sequence a (n). Try changing the value of \
  3. "x".*)
  4. coeff = Join[{1, x}, (-x)^(Range[20])]
  5. mp[m_, e_] :=
  6. If[e == 0, IdentityMatrix@Length@m, MatrixPower[m, e]]; nn =
  7. Length[coeff]; cc = Range[nn]*0 + 1; Monitor[
  8. Do[Clear[t]; t[n_, 1] := t[n, 1] = cc[[n]];
  9. t[n_, k_] :=
  10. t[n, k] =
  11. If[n >= k,
  12. Sum[t[n - i, k - 1], {i, 1, k - 1}] -
  13. Sum[t[n - i, k], {i, 1, k - 1}], 0];
  14. A4 = Table[Table[t[n, k], {k, 1, nn}], {n, 1, nn}];
  15. A5 = A4[[1 ;; nn - 1]]; A5 = Prepend[A5, ConstantArray[0, nn]];
  16. cc = Total[
  17. Table[coeff[[n]]*mp[A5, n - 1][[All, 1]], {n, 1, nn}]];, {i, 1,
  18. nn}], i]; cc
  19. Join[{1}, x*(x - 1)^Range[0, Length[coeff] - 2]]
  20. %% - %
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement