Skip to main content
fixed formula
Source Link
Neil
  • 184.3k
  • 12
  • 76
  • 290

Charcoal, 26 bytes

FLθ⊞υEθ⎇ι↨…§υ⊖ιλι¬λIEυΣ×θι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨…§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k) + k S(n - 2, k) + k^2 S(n - 3, k) + \dots \$\$ S(n, k) = S(n - 1, k - 1) + k S(n - 2, k - 1) + k^2 S(n - 3, k - 1) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

IEυΣ×θι

Output the dot product of each row of S with the input.

Charcoal, 26 bytes

FLθ⊞υEθ⎇ι↨…§υ⊖ιλι¬λIEυΣ×θι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨…§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k) + k S(n - 2, k) + k^2 S(n - 3, k) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

IEυΣ×θι

Output the dot product of each row of S with the input.

Charcoal, 26 bytes

FLθ⊞υEθ⎇ι↨…§υ⊖ιλι¬λIEυΣ×θι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨…§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k - 1) + k S(n - 2, k - 1) + k^2 S(n - 3, k - 1) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

IEυΣ×θι

Output the dot product of each row of S with the input.

Source Link
Neil
  • 184.3k
  • 12
  • 76
  • 290

Charcoal, 26 bytes

FLθ⊞υEθ⎇ι↨…§υ⊖ιλι¬λIEυΣ×θι

Attempt This Online! Link is to verbose version of code. I/O is a list of coefficients in ascending order. Explanation: Uses @Arnauld's formula along with dynamic programming to calculate the Stirling numbers of the second kind.

FLθ

Loop for \$ k \$ from \$ 0 \$ to \$ n \$.

⊞υEθ⎇ι↨…§υ⊖ιλι¬λ

Calculate \$ S(n, k) = S(n - 1, k) + k S(n - 2, k) + k^2 S(n - 3, k) + \dots \$ as this is a more convenient way to generate a transposed array S[k][n].

IEυΣ×θι

Output the dot product of each row of S with the input.