Advertisement
MatsGranvik

Convolution with divisor recurrence giving powers of 2

Mar 12th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Clear[t, n, k, i, nn, x]
  2. coeff = {1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
  3. nn = Length[coeff]
  4. cc = Range[nn]*0 + 1;
  5. Monitor[Do[
  6. Clear[t];
  7. t[n_, 1] := t[n, 1] = cc[[n]];
  8. t[n_, k_] :=
  9. t[n, k] =
  10. If[n >= k,
  11. Sum[t[n - i, k - 1], {i, 1, k - 1}] -
  12. Sum[t[n - i, k], {i, 1, k - 1}], 0];
  13. A4 = Table[Table[t[n, k], {k, 1, nn}], {n, 1, nn}];
  14. A5 = A4[[1 ;; nn - 1]];
  15. A5 = Prepend[A5, ConstantArray[0, nn]];
  16. cc = Total[
  17. Table[coeff[[n]]*MatrixPower[A5, n - 1][[All, 1]], {n, 1, nn}]];
  18. , {i, 1, nn}], i]
  19. cc
  20. CoefficientList[Series[(1 + x)/(1 + 2*x), {x, 0, nn - 1}], x]
  21. Flatten[{1, Table[(-(-2)^(n - 1)), {n, 1, 28 - 1}]}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement