Derivative of a Polynomial
Goal: Determine the coefficients of the derivative of the polynomial p(X) where
p(X) = a_n * x^n + a_(n-1) * x^(n-1) + ... + a1 * x + a0
and
d/dX p(X) = a_n * n * x^(n-1) + a_(n-1) * (n-1) * x^(n-2) + ... + a1
Where a_n, a_(n-1), ... , a1, a0 are stored in lists. The coefficients are listed in order of descending powers of x. Use zeros as placeholders.
Example:
d/dx -2x^2 + 4x - 6 = -4x + 4
Input List: {-2, 4, -6}
Output List: {-4, 4}
d/dx x^4 + 3x^2 - x = 4x^3 + 6x - 1
Input List: {1, 0, 3, -1, 0}
Output List: {4, 0, 6, -1}
For all three programs, the input is List 1, the output is List 2.
Casio Prizm:
POLYDX
Polynomial Derivative - 132 bytes
"d/dX P(X)"
"{AnX^n,...,A0}"
"LIST:"? → List 1
Dim List 1-1 → Dim List 2
For 1→K To Dim List 2
(Dim List 1-K) × List 1[K] → List 2[K]
Next
List 2
TI-84+:
POLYDX
Polynomial Derivative - 118 bytes
: Disp "D/DX P(X)", "{AnX^n,...,A0}"
: Input "LIST:",L1
: L1->L2
: dim(L2)-1->dim(L2)
: For(K,1,dim(L2))
: (dim(L2)-(K-1))*L2(K)->L2(K)
: End
: Pause L2
HP 39gii:
Polynomial Derivative
11/23/2012 - edited 12/2/2012
POLYDX()
EXPORT POLYDX()
BEGIN
LOCAL K,S;
EDITLIST(L1);
SIZE(L1)→S;
{ } → L2;
FOR K FROM 1 TO S-1 DO
CONCAT(L2, {(S-K)*L1(K)}) → L2;
END;
RETURN L2;
END;
This blog is property of Edward Shore. 2012
A blog is that is all about mathematics and calculators, two of my passions in life.