Point-free madness

Haskell, 278+448/8-300=34

(foldr.pure.pure.((++).(foldr(('(':).(++".)")<$id).((++).("(sum.zipWith(*)"++).show.map head<*>(".flip(map.(product.).zipWith(^))"++).(++")").show.map tail)<*>tail.head)<*>(++" pure)").("("++).foldr(("(("++).(++".flip(:)).)")<$id)"id".drop 2.head))<*>show.sum.concat<*>tail.head

Saved 14 bytes by having a closer look at parens as suggested by @Damien, then saved 8 more using another hint from them.

Since input is "list of Integers in any format you want", I take list of lists with first elements the multiplicative constants of the summands, and the rest all the corresponding exponents in reverse order. So the example polynomial 5*a^5+2*a*b^3+8 is given by [[5,0,5],[2,3,1],[8,0,0]]. (Didn't try [(5,[0,5]),(2,[3,1]),(8,[0,0])] - would that be allowed?)

The result for this example polynomial is this:

(((sum.zipWith(*)[5,2,8].flip(map.(product.).zipWith(^))[[0,5],[3,1],[0,0]]).).)(((id.flip(:)).) pure)

See the results for the test cases or try your own polynomial at the TIO-Link:

Try it online!

Check the results for the test cases here:

Check it online! (testing code from OP with my results)


05AB1E, score: 167 (111 bytes + 448/8)

¬g©i˜Oëøć',ý’.Œ¬With(’DŠ’(¬€ÿ*)[ÿ].ÒÀ(‚é.(‚ª.)ÿ^))’sø',ý€…[ÿ]',ý…[ÿ]s…ÿÿ)®G"(ÿ.)"}„id®ÍF’((ÿ.ÒÀ(:)).)’}s“ÿ(ÿ©¬)

Since I don't know Haskell, I figured I'd just port the output of @ChristianSievers' Haskell answer, so make sure to upvote him!!
Input is taken in a similar matter as well (first being the multiplicative constant, and after that the exponents in reverse order). So for example: test case \$5a^4b^3c^2+a^2b^3c^4d^5\$ is given as input-list [[5,0,2,3,4],[1,5,4,3,2]].

Try it online or verify all test cases.
Verify the outputs with OP's validator.

Explanation:

¬                       # Get the first inner list in the (implicit) input-list
 g                      # Get the length of that list
  ©                     # And store it in variable ® (without popping)
i                       # If that length is 1:
 ˜O                     #  Take the flattened sum of the input-list
ë                       # Else:
 ø                      #  Zip/transpose the input-list; swapping rows/columns
  ć                     #  Extract head; pop and push head and remainder
   ',ý                 '#  Join this first list by ","
      ’.Œ¬With(’        #  Push dictionary String ".zipWith("
                D       #  Duplicate it
                 Š      #  Triple swap the items on the stack (a,b,c → c,a,b)
   ’(¬€ÿ*)[ÿ].ÒÀ(‚é.(‚ª.)ÿ^))’
                        #  Push dictionary string "(sumÿ*)[ÿ].flip(map.(product.)ÿ^))",
                        #  where the three ÿ are filled with the values on the stack
   s                    #  Swap to take the remainder again
    ø                   #  Zip/transpose it back
     ',ý               '#  Join each inner-most list by ","
        €…[ÿ]           #  Surround each inner string in []-blocks
             ',ý       '#  Join those by "," again
                …[ÿ]    #  And surround the entire thing by []-blocks again
    s                   #  Swap the two strings on the stack
     …ÿÿ)               #  And fill them in into the string "ÿÿ)"
 ®G      }              #  Now loop ®-1 amount of times:
   "(ÿ.)"               #   And fill in the top string on the stack into string "(ÿ.)"
 „id                    #  Then push string "id"
    ®ÍF              }  #  Loop ®-2 amount of times:
       ’((ÿ.ÒÀ(:)).)’   #   And fill the top string of the stack into dictionary 
                        #   string "((ÿ.flip(:)).)"
 s                      #  Swap the two strings of the stack again
  “ÿ(ÿ©¬)               #  And fill them into the dictionary string "ÿ( pure)"
                        # (after which the result is output implicitly)

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why:

  • ’.Œ¬With(’ is ".zipWith("
  • ’(¬€ÿ*)[ÿ].ÒÀ(‚é.(‚ª.)ÿ^))’ is "(sumÿ*)[ÿ].flip(map.(product.)ÿ^))"
  • ’((ÿ.ÒÀ(:)).)’ is "((ÿ.flip(:)).)"
  • “ÿ(ÿ©¬) is "ÿ( pure)"

Unfortunately ÿ doesn't work for inner items in a list and requires an explicit , otherwise ',ý€…[ÿ]',ý…[ÿ] could have been 2F',ý…[ÿ]} instead.