Поскольку вы просили мои реализации (у них f
"назад"):
Уравнение 2:
from math import factorial
from collections import defaultdict
def binomial(n, k):
try:
binom = factorial(n) // factorial(k) // factorial(n - k)
except ValueError:
binom = 0
return binom
f = [1, 2, 3, -4, 5, 6, -7, 8, 9][::-1]
k=0
n = len(f) - 1
g = defaultdict(int)
for k in range(n+1):
for i in range(k, n+1):
g[i-k] += binomial(i,k) * f[i]
print(g)
# defaultdict(<class 'int'>, {0: 23, 1: 52, 2: 116, 3: 172, 4: 170, 5: 112, 6: 45, 7: 10, 8: 1})
Уравнение в 2.2 (F):
from math import factorial
from collections import defaultdict
def convolve(x, y):
g = defaultdict(int)
for (xi, xv) in x.items():
for (yi, yv) in y.items():
g[xi + yi] += xv * yv
return g
def shift(f, a):
n = len(f) - 1
u = {n-i: factorial(i)*c for (i, c) in enumerate(f)}
v = {j: factorial(n)*a**j//factorial(j) for j in range(n + 1)}
uv = convolve(u, v)
def g(k):
ngk = uv[n-k]
return ngk // factorial(n) // factorial(k)
G = [g(k) for k in range(n+1)]
return G
f = [1, 2, 3, -4, 5, 6, -7, 8, 9]
print(shift(f, 1))
# [23, 132, 396, 720, 840, 636, 301, 80, 9]