Polynomial derivative: Difference between revisions
Add Factor
JsfasdF256 (talk | contribs) No edit summary |
(Add Factor) |
||
Line 1:
{{draft task}}
Given a polynomial, represented by an ordered list of its coefficients by increasing degree (e.g. [-1, 6, 5] represents 5x<sup>2</sup>+6x-1), calculate the polynomial representing the derivative. For example, the derivative of the aforementioned polynomial is 10x+6, represented by [6, 10].
=={{header|Factor}}==
<lang factor>USING: math.polynomials prettyprint ;
{ -1 6 5 } pdiff .</lang>
{{out}}
<pre>
{ 6 10 }
</pre>
The implementation of <code>pdiff</code>:
<lang factor>: pdiff ( p -- p' ) dup length <iota> v* rest ;</lang>
|