[Common Math 1 Part 2] Polynomial Operations and Arrays

한국어 버전

If Part 1 sketched the full structure of Common Math 1, this article moves into our first unit: polynomial addition and subtraction. We will represent polynomials with coefficient arrays, use that representation to explain why the commutative and associative laws feel natural, and briefly preview how the same idea extends to two variables.

1. When Polynomials Meet Arrays

In high school, we often accept that polynomial addition follows the commutative and associative laws without looking closely at the reason. Once we rewrite a polynomial as a list of coefficients, the reason becomes much easier to see.

1.1 Expressing a Polynomial as an Array

Writing a polynomial as an array makes each operation more transparent. In this article, we always list coefficients from the highest power down to the constant term.

If

P(x)=anxn+an1xn1++a1x+a0,P(x) = a_nx^n + a_{n-1}x^{n-1} + \cdots + a_1x + a_0,

then we store it as

[an,an1,,a1,a0].[a_n, a_{n-1}, \ldots, a_1, a_0].

So each position in the array corresponds to a specific power of xx, and the value in that position is the coefficient.

Example:

  • P(x)=3x2+2x+5P(x) = 3x^2 + 2x + 5[3, 2, 5] from highest degree downward
  • Q(x)=x2+4x+1Q(x) = x^2 + 4x + 1[1, 4, 1]

The key is that coefficients of the same power line up in matching positions. After that alignment, addition and subtraction become position-by-position operations. Multiplication is different, so in this post we focus on addition and subtraction first.

If a power is missing, we insert 0 in that position.

  • x3+2x^3 + 2 becomes [1, 0, 0, 2]
  • [[5x-2|5x2]]:x5x^2]]: x becomes [5, -1, 0] if we only write the terms that appear
  • To align it with a cubic, we pad it as [0, 5, -1, 0]

This zero-padding step is what makes array addition work even when two polynomials have different degrees.

A 1-D array is just an ordered list

For this article, you do not need geometry. The important idea is simple: [3, 2, 5] is an ordered list of coefficients.

  • First slot: coefficient of x2x^2
  • Second slot: coefficient of xx
  • Third slot: constant term

If two polynomials use the same ordering and the same length, their addition works like adding two ordered lists entry by entry.

🎯 Try it: Enter a polynomial below to see how it becomes an array in real time.

1변수 다항식 → 배열 변환기

단일 화면 애니메이션으로 계수 배열 추출

준비
0%
x만 지원 누락 차수는 0으로 채움
허용 예시 3x^2 + 2x + 5x^3 - 4x + 12x^4 + 7
피해야 할 입력 3y^2 + 2y + 53x2 + 2x3x^ + 1
정규화된 식 3x2 + 2x + 5
1
원본 다항식
2
항 분리
3
계수 강조
4
배열 형성
5
완성

현재 단계

준비

다항식을 입력하고 변환 버튼을 누르면 단계별로 계수를 추출합니다.

3 3 x2 +2 2 x +5 5
3
2
5
입력 다항식 3x2 + 2x + 5
[ 3 ,2 ,5 ]
[3, 2, 5]
추출된 계수 배열

식의 구조를 먼저 보고 어떤 계수가 필요한지 확인합니다.

1.2 Adding Polynomials via Arrays

Why bother with arrays?

Traditional polynomial addition tells you to “combine like terms.” For (3x2+2x+5)+(x2+4x+1),(3x^2 + 2x + 5) + (x^2 + 4x + 1), you hunt for x2x^2 terms, then xx terms, then constants.

With arrays the process collapses to a single idea: once the coefficients are aligned by power, you add matching positions.

[3,2,5]+ [1,4,1]=[4,6,6]\begin{aligned} &[3, 2, 5] \\ +\ &[1, 4, 1] \\ \hline =& [4, 6, 6] \end{aligned}
  • First entry: 3+1=43 + 1 = 4 (coefficient of x2x^2)
  • Second: 2+4=62 + 4 = 6 (coefficient of xx)
  • Third: 5+1=65 + 1 = 6 (constant term)

So array addition mirrors polynomial addition.

Here is the same idea with different degrees:

x3+2[1,0,0,2]5x2x[0,5,1,0]\begin{aligned} x^3 + 2 &\rightarrow [1, 0, 0, 2] \\ 5x^2 - x &\rightarrow [0, 5, -1, 0] \end{aligned}

Now we can add position by position:

[1,0,0,2]+[0,5,1,0]=[1,5,1,2],[1, 0, 0, 2] + [0, 5, -1, 0] = [1, 5, -1, 2],

which corresponds to x3+5x2x+2x^3 + 5x^2 - x + 2.

Benefits

  • Computer-friendly: arrays live in contiguous memory, so access is fast.
  • Parallelizable: each index is independent, so GPUs can add them simultaneously.
  • Scales smoothly: any degree works the same way.

NumPy specializes in this style of work. After the math idea is clear, we can use np.array to store coefficients and let Python add matching entries for us.

💻 Python (NumPy)

P = np.array([3, 2, 5])  # 3x² + 2x + 5
Q = np.array([1, 4, 1])  # x² + 4x + 1

# Element-wise addition
result = P + Q
print(f"P + Q = {result}")  # [4 6 6]
print(f"Polynomial: {result[0]}x² + {result[1]}x + {result[2]}")

# Or call np.polyadd
result2 = np.polyadd(P, Q)
print(f"np.polyadd: {result2}")

2. The Secret Behind the Laws

2.1 Why Do the Commutative and Associative Laws Hold?

Commutative law (A+B=B+AA + B = B + A)

Once polynomials are written in a fixed coefficient order, polynomial addition is defined position by position. Each pair of coefficients is a real number, so pi+qi=qi+pip_i + q_i = q_i + p_i by the commutative law of real-number addition.

[3,2,5]+[1,4,1]=[1,4,1]+[3,2,5]=[4,6,6].[3, 2, 5] + [1, 4, 1] = [1, 4, 1] + [3, 2, 5] = [4, 6, 6].

Associative law ((A+B)+C=A+(B+C)(A + B) + C = A + (B + C))

For the same reason, grouping does not matter. Each position follows the associative law of real-number addition.

You can even verify it directly with np.array_equal:

💻 Python (NumPy)

A = np.array([2, 3, -1, 4])  # 2x³ + 3x² - x + 4
B = np.array([1, -2, 3, 1])  # x³ - 2x² + 3x + 1
C = np.array([0, 1, 0, 2])   # x² + 2

left = (A + B) + C
right = A + (B + C)

print(np.array_equal(left, right))  # True
print(f"(A + B) + C = {left}")
print(f"A + (B + C) = {right}")

print(f"A + B == B + A: {np.array_equal(A + B, B + A)}")

Summary

Law Array formulation Based on
Commutative [pi]+[qi]=[qi]+[pi][p_i] + [q_i] = [q_i] + [p_i] Commutative law of real-number addition
Associative ([ai]+[bi])+[ci]=[ai]+([bi]+[ci])([a_i] + [b_i]) + [c_i] = [a_i] + ([b_i] + [c_i]) Associative law of real-number addition

2.2 Check With Practice Problems

Problem 1 Express the following polynomials as arrays and add them:

  • A(x)=2x3+3x2x+4A(x) = 2x^3 + 3x^2 - x + 4
  • B(x)=x32x2+3x+1B(x) = x^3 - 2x^2 + 3x + 1

Solution

  • AA[2, 3, -1, 4]
  • BB[1, -2, 3, 1]
  • A+BA + B[3, 1, 2, 5]
  • Converted back: 3x3+x2+2x+53x^3 + x^2 + 2x + 5

Problem 2 Explain why the following equality holds using array operations: (2x2+3x+1)+(x22x+4)=(x22x+4)+(2x2+3x+1).(2x^2 + 3x + 1) + (x^2 - 2x + 4) = (x^2 - 2x + 4) + (2x^2 + 3x + 1).

Solution

  • Left: [2, 3, 1] + [1, -2, 4] = [3, 1, 5]
  • Right: [1, -2, 4] + [2, 3, 1] = [3, 1, 5]
  • Therefore the equality holds by the commutative law.

🧠 Practice: Convert polynomials to arrays and add/subtract them in the quiz below.

다항식 배열 변환 퀴즈

문제별 계수 배열 입력과 즉시 피드백

다항식 배열 변환 퀴즈

1 / 3
진행률 33%

Write the polynomial in array form (descending):

3x^{2} + 2x + 5

형식: [x²계수, x계수, 상수] (예: [3, 2, 5])

3. The Principle Behind Subtraction

3.1 Negating an Array Equals Multiplying by −1

Subtraction is just a special form of addition: subtracting Q(x)Q(x) means adding Q(x)-Q(x).

If

Q(x)=q2x2+q1x+q0,Q(x) = q_2x^2 + q_1x + q_0,

then its coefficient array is [q_2, q_1, q_0], and the coefficient array of Q(x)-Q(x) is [-q_2, -q_1, -q_0]. In other words, multiply every entry by -1.

Example

P(x)=3x2+2x+5P(x) = 3x^2 + 2x + 5[3, 2, 5]

Q(x)=x2+4x+1Q(x) = x^2 + 4x + 1[1, 4, 1]

Steps for P(x)Q(x)P(x) - Q(x):

  1. Flip QQ’s signs: Q(x)=x24x1-Q(x) = -x^2 - 4x - 1[-1, -4, -1]
  2. Add: [3, 2, 5] + [-1, -4, -1] = [2, -2, 4]
  3. Convert back: 2x22x+42x^2 - 2x + 4

This works because subtraction can reuse the same algorithm as addition—just apply a sign change.

NumPy uses the - operator or np.polysub to do the job; -Q automatically multiplies each entry by −1.

💻 Python (NumPy)

P = np.array([3, 2, 5])
Q = np.array([1, 4, 1])

result = P - Q
print(f"P - Q = {result}")  # [ 2 -2  4]

result2 = np.polysub(P, Q)
print(f"np.polysub: {result2}")

negative_Q = -Q
print(f"-Q = {negative_Q}")

result3 = P + (-Q)
print(f"P + (-Q) = {result3}")

3.2 Practice

Problem 3 Given A(x)=x2+3x2A(x) = x^2 + 3x - 2 and B(x)=2x2x+5B(x) = 2x^2 - x + 5, find 2AB2A - B with arrays.

Solution

  • AA[1, 3, -2]
  • BB[2, -1, 5]
  • 2A2A[2, 6, -4]
  • 2AB2A - B[0, 7, -9]7x97x - 9

Scalar multiplication (2 * A) is also element-wise, so NumPy handles it directly:

💻 Python (NumPy)

P = np.array([3, 2, 5])
Q = np.array([1, 4, 1])
print(f"P - Q = {P - Q}")

A = np.array([1, 3, -2])
B = np.array([2, -1, 5])
print(f"2A - B = {2 * A - B}")

💡 Takeaway: once we write polynomials as coefficient arrays in a fixed order, addition and subtraction follow the same laws as real-number addition. The array representation makes that structure visible.

🎯 Keep practicing:

다항식 덧셈/뺄셈 연습

3단계(배열 변환 → 배열 연산 → 과정 확인)

다항식 덧셈/뺄셈 연습

Phase 1/3
배열 변환 33%

주어진 다항식을 배열로 변환하세요

A(x) = 0

B(x) = 0

Q1. A(x)를 배열로 표현하시오

Q2. B(x)를 배열로 표현하시오

4. Next Step: Moving to Two Variables

We now understand how 1-variable polynomials behave as arrays. The next step is to organize coefficients for polynomials in two variables.

4.1 Why Two Variables?

Many real phenomena cannot be described with a single variable:

Field Example Variables
Physics Electric field distribution E(x,y)E(x, y)
Economics Cost function C(x,y)C(x, y) (usage of two materials)
Image processing Pixel intensity 2‑D position (x,y)(x, y)
Meteorology Temperature map T(lat,lon)T(\text{lat}, \text{lon})

4.2 Arrays Become Matrices

For P(x,y)=3x2y+2xy2+5x+7y+1P(x, y) = 3x^2y + 2xy^2 + 5x + 7y + 1, we use a coefficient matrix. Each entry records the coefficient of one power pair xiyjx^iy^j.

For this example:

  • 11 is the coefficient of x0y0x^0y^0
  • 7y7y is the coefficient of x0y1x^0y^1
  • 5x5x is the coefficient of x1y0x^1y^0
  • 2xy22xy^2 is the coefficient of x1y2x^1y^2
  • 3x2y3x^2y is the coefficient of x2y1x^2y^1
P=[170502030]P = \begin{bmatrix} 1 & 7 & 0 \\ 5 & 0 & 2 \\ 0 & 3 & 0 \end{bmatrix}
  • Rows follow powers of xx (x0,x1,x2x^0, x^1, x^2)
  • Columns follow powers of yy (y0,y1,y2y^0, y^1, y^2)

So a 1-variable polynomial uses a 1-D coefficient array, while a 2-variable polynomial uses a 2-D coefficient matrix. Just as before, addition works by matching entries that represent the same powers.

4.3 Coming Up Next

In Part 3: Bivariate Polynomials and Matrices we will explore

  • How multivariable polynomials map to matrices
  • How matrix addition mirrors polynomial operations
  • Real-world cases in image processing and simulations

5. Wrap-Up

We learned how coefficient arrays organize polynomial terms and make addition and subtraction easier to explain. Once coefficients are aligned by power, the commutative and associative laws follow directly from the corresponding laws for real numbers.

With 1-variable polynomials organized this way, we now have the basic structure in hand, and we have even glimpsed how it begins to extend to two variables. In the next part, we make that extension fully explicit.

Next: Bivariate Polynomials and Matrices →

💬 댓글

이 글에 대한 의견을 남겨주세요