Can somebody explain to me why equating coefficients work?

Example:
8x^3+13x = Ax^3 + 2Ax + Bx^2 + 2B + Cx + D

expanded into:

8x^3 + 13x = Ax^3 + Bx^2 + (2A+C)x + 2(B+D)

where A,B,C,D are constants.

Why does 8 = A; 0 = B; 13 = 2A + C; etc.

I know they have same power variables, but why does this actually work? Thanks!

8x^3+13x ≡ Ax^3 + 2Ax + Bx^2 + 2B + Cx + D ...(1)

=>
(8-A)x^3-Bx²+(13-2A-C)x -(2B+C)≡ 0 ...(2)

This is an identity, and has to work for all values of x.
This can happen if and only if the coefficients on the left-hand side of (2) are zero, which then implies
8-A=0, or A=8,
etc.

Equating coefficients is a process used in algebra to solve equations that involve multiple terms with the same variables raised to different powers. It allows us to compare the coefficients of these terms and set them equal to each other. By setting the coefficients equal, we essentially equate the numerical values on both sides of the equation and establish a relationship between the variables, which can help us solve for unknowns.

In the given example, we have the equation:

8x^3 + 13x = Ax^3 + Bx^2 + (2A+C)x + 2(B+D)

To equate the coefficients, we compare the coefficients of corresponding terms on both sides of the equation.

1. Comparing the coefficients of x^3 on both sides:
8x^3 = Ax^3
Since the variable powers are the same (x^3), the coefficients must be equal: 8 = A

2. Comparing the coefficients of x^2 on both sides:
0x^2 = Bx^2
Since B is a constant and x^2 has no coefficient on the left side, we can determine that B must be zero (0 = B).

3. Comparing the coefficients of x on both sides:
13x = (2A+C)x
Again, the variable powers are the same (x), so the coefficients must be equal: 13 = 2A + C

4. Comparing the constant terms on both sides:
0 = 2(B+D)
Since B is zero (as determined earlier), we can deduce that D must also be zero (0 = 2D).

By equating the coefficients, we have established the relationships:

A = 8
B = 0
2A + C = 13
2B + 2D = 0

These relationships allow us to determine the values of the constants A, B, C, and D based on the given equation. Equating coefficients gives us a way to solve for these unknowns in a systematic manner, making use of the properties and rules of algebra.