Skip to main content
added 221 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 16 bytes

Ḣ;J€×J+ŻƲ{\×"⁸SƲ

A monadic Link that accepts a list of integers, the monomial coefficients in ascending order and yields the falling factorial coefficients in ascending order.

Try it online! Or see the test-suite (showing I/O in descending order).

Note: a constant polynomial (an input of length one) yields an additional, redundant zero coefficient at \$x_1\$, I'm guessing that's acceptable, if not Ḣ;ȧJ€×J+ŻƲ{\×"⁸SƲ$ would work for \$18\$ bytes.

How?

Effectively employs the recurrence relation of Stirling numbers of the second kind, \$S(n, k)\$:

$$S(n+1, k) = k S(n, k) + S(n, k-1) \space \vert \space 0 \lt k \lt n$$ $$S(n, 0) = S(0, k) = 0$$ $$S(n, n) = 1$$

Ḣ;J€×J+ŻƲ{\×"⁸SƲ - Link: list of integers, C
Ḣ                - behead C -> removes the constant term, N, from C
               Ʋ - last four links as a monad - f(Rest)
  J€             -   range of length of each -> [[1], [1], ..., [1]]
          \      -   cumulative reduce by:
        Ʋ{       -     last four links as a monad - f(Current (initially [1])):
     J           -       range of length -> [1..length(Current)]
    ×            -       {Current} multiplied by {that} (vectorises) -> M
       Ż         -       prefix {Current} with a zero
      +          -       {M} add {[0]+Current} (vectorises) -> next Current
           ×"⁸   -   {that} zipwise multiplied by {Rest}
              S  -   column-wise sum
 ;               - {N} concatenate {that}

Jelly, 16 bytes

Ḣ;J€×J+ŻƲ{\×"⁸SƲ

A monadic Link that accepts a list of integers, the monomial coefficients in ascending order and yields the falling factorial coefficients in ascending order.

Try it online! Or see the test-suite (showing I/O in descending order).

Note: a constant polynomial (an input of length one) yields an additional, redundant zero coefficient at \$x_1\$, I'm guessing that's acceptable, if not Ḣ;ȧJ€×J+ŻƲ{\×"⁸SƲ$ would work for \$18\$ bytes.

How?

Ḣ;J€×J+ŻƲ{\×"⁸SƲ - Link: list of integers, C
Ḣ                - behead C -> removes the constant term, N, from C
               Ʋ - last four links as a monad - f(Rest)
  J€             -   range of length of each -> [[1], [1], ..., [1]]
          \      -   cumulative reduce by:
        Ʋ{       -     last four links as a monad - f(Current (initially [1])):
     J           -       range of length -> [1..length(Current)]
    ×            -       {Current} multiplied by {that} (vectorises) -> M
       Ż         -       prefix {Current} with a zero
      +          -       {M} add {[0]+Current} (vectorises) -> next Current
           ×"⁸   -   {that} zipwise multiplied by {Rest}
              S  -   column-wise sum
 ;               - {N} concatenate {that}

Jelly, 16 bytes

Ḣ;J€×J+ŻƲ{\×"⁸SƲ

A monadic Link that accepts a list of integers, the monomial coefficients in ascending order and yields the falling factorial coefficients in ascending order.

Try it online! Or see the test-suite (showing I/O in descending order).

Note: a constant polynomial (an input of length one) yields an additional, redundant zero coefficient at \$x_1\$, I'm guessing that's acceptable, if not Ḣ;ȧJ€×J+ŻƲ{\×"⁸SƲ$ would work for \$18\$ bytes.

How?

Effectively employs the recurrence relation of Stirling numbers of the second kind, \$S(n, k)\$:

$$S(n+1, k) = k S(n, k) + S(n, k-1) \space \vert \space 0 \lt k \lt n$$ $$S(n, 0) = S(0, k) = 0$$ $$S(n, n) = 1$$

Ḣ;J€×J+ŻƲ{\×"⁸SƲ - Link: list of integers, C
Ḣ                - behead C -> removes the constant term, N, from C
               Ʋ - last four links as a monad - f(Rest)
  J€             -   range of length of each -> [[1], [1], ..., [1]]
          \      -   cumulative reduce by:
        Ʋ{       -     last four links as a monad - f(Current (initially [1])):
     J           -       range of length -> [1..length(Current)]
    ×            -       {Current} multiplied by {that} (vectorises) -> M
       Ż         -       prefix {Current} with a zero
      +          -       {M} add {[0]+Current} (vectorises) -> next Current
           ×"⁸   -   {that} zipwise multiplied by {Rest}
              S  -   column-wise sum
 ;               - {N} concatenate {that}
added 832 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 16 bytes

Ḣ;J€×J+ŻƲ{\×"⁸SƲ

A monadic Link that accepts a list of integers, the monomial coefficients in ascending order and yields the falling factorial coefficients in ascending order.

Try it online! Or see the test-suite (showing I/O in descending order).

Note: a constant polynomial (an input of length one) yields an additional, redundant zero coefficient at \$x_1\$, I'm guessing that's acceptable, if not Ḣ;ȧJ€×J+ŻƲ{\×"⁸SƲ$ would work for \$18\$ bytes.

How?

Ḣ;J€×J+ŻƲ{\×"⁸SƲ - Link: list of integers, C
Ḣ                - behead C -> removes the constant term, N, from C
               Ʋ - last four links as a monad - f(Rest)
  J€             -   range of length of each -> [[1], [1], ..., [1]]
          \      -   cumulative reduce by:
        Ʋ{       -     last four links as a monad - f(Current (initially [1])):
     J           -       range of length -> [1..length(Current)]
    ×            -       {Current} multiplied by {that} (vectorises) -> M
       Ż         -       prefix {Current} with a zero
      +          -       {M} add {[0]+Current} (vectorises) -> next Current
           ×"⁸   -   {that} zipwise multiplied by {Rest}
              S  -   column-wise sum
 ;               - {N} concatenate {that}

Jelly, 16 bytes

Ḣ;J€×J+ŻƲ{\×"⁸SƲ

A monadic Link that accepts a list of integers, the monomial coefficients in ascending order and yields the falling factorial coefficients in ascending order.

Try it online! Or see the test-suite (showing I/O in descending order).

Note: a constant polynomial (an input of length one) yields an additional, redundant zero coefficient at \$x_1\$, I'm guessing that's acceptable, if not Ḣ;ȧJ€×J+ŻƲ{\×"⁸SƲ$ would work for \$18\$ bytes.

Jelly, 16 bytes

Ḣ;J€×J+ŻƲ{\×"⁸SƲ

A monadic Link that accepts a list of integers, the monomial coefficients in ascending order and yields the falling factorial coefficients in ascending order.

Try it online! Or see the test-suite (showing I/O in descending order).

Note: a constant polynomial (an input of length one) yields an additional, redundant zero coefficient at \$x_1\$, I'm guessing that's acceptable, if not Ḣ;ȧJ€×J+ŻƲ{\×"⁸SƲ$ would work for \$18\$ bytes.

How?

Ḣ;J€×J+ŻƲ{\×"⁸SƲ - Link: list of integers, C
Ḣ                - behead C -> removes the constant term, N, from C
               Ʋ - last four links as a monad - f(Rest)
  J€             -   range of length of each -> [[1], [1], ..., [1]]
          \      -   cumulative reduce by:
        Ʋ{       -     last four links as a monad - f(Current (initially [1])):
     J           -       range of length -> [1..length(Current)]
    ×            -       {Current} multiplied by {that} (vectorises) -> M
       Ż         -       prefix {Current} with a zero
      +          -       {M} add {[0]+Current} (vectorises) -> next Current
           ×"⁸   -   {that} zipwise multiplied by {Rest}
              S  -   column-wise sum
 ;               - {N} concatenate {that}
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 16 bytes

Ḣ;J€×J+ŻƲ{\×"⁸SƲ

A monadic Link that accepts a list of integers, the monomial coefficients in ascending order and yields the falling factorial coefficients in ascending order.

Try it online! Or see the test-suite (showing I/O in descending order).

Note: a constant polynomial (an input of length one) yields an additional, redundant zero coefficient at \$x_1\$, I'm guessing that's acceptable, if not Ḣ;ȧJ€×J+ŻƲ{\×"⁸SƲ$ would work for \$18\$ bytes.