Python oneliner to differentiate polynomial list: Difference between revisions
From wikiluntti
(Created page with "== Introduction == Oneliners are powerful and often beautiful solutions to programming challenges (see [https://www.ee.columbia.edu/~marios/matlab/Matlab%20array%20manipulati...") |
(→Theory) |
||
Line 13: | Line 13: | ||
print( [(i+1)*j for i,j in enumerate( poly[1:] )] ) | print( [(i+1)*j for i,j in enumerate( poly[1:] )] ) | ||
<syntaxhighlight> | </syntaxhighlight> |
Revision as of 11:39, 5 August 2021
Introduction
Oneliners are powerful and often beautiful solutions to programming challenges (see Acklamization).
Theory
- D(poly) = 2*0 + 3*1 + 5*2 + 1*3
- Dpoly = [3, 10, 3]
poly = [2, 3, 5, 1] # Degrees starting from zero
print( [(i+1)*j for i,j in enumerate( poly[1:] )] )