Sunday, December 2, 2012

Numeric CAS - Part 4: Polynomial Multiplication

Polynomial Multiplication

Goal: Multiply two polynomials: p1(x) * p2(x) = p3(x)

Inputs: Coefficients of p1(x) and p2(x) as List 1 and List 2, respectively

Output: Coefficients of p3(x) as List 3.

The lists are in order from highest order to constant. Zeros are used as place holders.

Example: (x^3 + 2x - 1) * (-2x^2 + x - 4) = -2x^5 + x^4 - 8x^3 + 4x^2 - 9x + 4

Input:
List 1: {1, 0, 2, -1}
List 2: {-2, 1, -4}

Output:
List 3: {-2, 1, -8, 4, -9, 4}


Casio Prizm:

POLYMULT
Multiplication of Two Polynomials
11/21/2012 - 176 bytes

"{AnX^n,...,A0}"
"P1(X)"? → List 1
"P2(X)"? → List 2
Dim List 1 + Dim List 2 - 1 → Dim List 3
For 1 → K To Dim List 1
List 1[K] × List 2 → List 4
For 1 → J To Dim List 4
List 3[J + K - 1] + List 4[J] → List 3[J + K - 1]
Next
Next
List 3


Example:
(x^2 + 3x - 1)(x^2 - 4) = x^4 + 3x^3 - 5x^2 - 12x + 4
List 1: {1,3,-1}
List 2: {1,0,-4}
Result List 3: {1,3,-5,-12,4}


TI-84+:

POLYMULT
Multiplication of two Polynomials
{AnX^n,...,A0}
11/21/2012 - 154 bytes

To get the lower case "n" character: VARS, 5, 1

Disp "{AnX^n,...,A0}"
Input "P1(X)=", L1
Input "P2(X)=", L2
dim(L1) + dim(L2) - 1 → dim(L3)
Fill(0,L3)
For(K, 1, dim(L1))
L1(K) * L2 → L4
For(J, 1, dim(L4))
L3(J + K - 1) + L4(J) → L3(J + K - 1)
End
End
Pause L3


HP 39gii:

Polynomial Multiplication (FULL)
12/2/2012

EXPORT POLYMULT()
BEGIN
LOCAL S,K,J;
EDITLIST(L1);
EDITLIST(L2);
SIZE(L1)+SIZE(L2)-1 → S;
MAKELIST(0,X,1,S,1) → L3;
FOR K FROM 1 TO SIZE(L1) DO
L1(K)*L2 → L4;
FOR J FROM 1 TO SIZE(L4) DO
L3(J+K-1) + L4(J) → L3(J+K-1);
END;
END;
RETURN L3;
END;





This blog is property of Edward Shore. 2012





Solving Simple Arcsine and Arccosine Equations

  Solving Simple Arcsine and Arccosine Equations Angle Measure This document will focus on angle measurement in degrees. For radia...