Algebra Terminology
Algebra has a small vocabulary that every later lesson relies on: terms, coefficients, constants, factors, degree and a few more. Knowing the exact words makes instructions like "combine like terms" or "factor out the coefficient" mean something precise. This lesson defines them on one running example and shows how SymPy can pull each part out of an expression.
Anatomy of an expression
Take the expression
| Word | Meaning | In the example |
|---|---|---|
| Term | a part separated by or (the sign belongs to the term) | , , , |
| Variable | a letter that stands for a number | , |
| Coefficient | the number multiplying the variables in a term | 5, −3, 7 |
| Constant | a term with no variable | −4 |
| Factor | something multiplied in a term | in : −3, and |
| Exponent / power | the small raised number | the 2 in |
| Degree of a term | sum of the exponents of its variables | : 2, : , : 1, : 0 |
| Degree of the expression | the highest degree of any term | 2 |
| Like terms | terms with exactly the same variables and powers | and are like; and are not |
Note: A term written as just has coefficient 1, and has coefficient −1. The 1 is invisible but it is there.
Expressions get names from their number of terms: a monomial has one term (), a binomial two (), a trinomial three (). Any sum of such terms with whole-number exponents is a polynomial, the subject of the Polynomials section.
Terms versus factors
The distinction between terms and factors is the most important one in this lesson.
- Terms are added. In , and 6 are terms.
- Factors are multiplied. In , 6 and are factors. In , the factors are 3 and .
Why it matters: you may cancel a common factor from a fraction, as in , but you may not cancel part of a term: is not . Most fraction mistakes in algebra come from mixing these up.
x = 9
print((x + 6) / 3) # the real value
print(x + 2) # the wrong "cancellation"
print(6 * x / 3, 2 * x) # cancelling a factor is fine5.0
11
18.0 18
Pulling the parts out with SymPy
SymPy knows this vocabulary. Add.make_args lists the terms, .coeff() reads a coefficient and degree gives the degree:
from sympy import symbols, Add, Poly, degree
x, y = symbols("x y")
e = 5*x**2 - 3*x*y + 7*y - 4
print("terms:", Add.make_args(e))
print("coefficient of x**2:", e.coeff(x, 2))
print("coefficient of x*y:", e.coeff(x*y))
print("constant:", e.as_coeff_add()[0])
print("degree:", Poly(e, x, y).total_degree())
print("degree in x only:", degree(e, x))terms: (-4, 5*x**2, 7*y, -3*x*y)
coefficient of x**2: 5
coefficient of x*y: -3
constant: -4
degree: 2
degree in x only: 2
SymPy stores terms in its own internal order, so the list does not match the order we wrote them in; the terms themselves are the same.
Equations, identities and solutions
| Word | Meaning | Example |
|---|---|---|
| Equation | a statement that two expressions are equal | |
| Solution / root | a value that makes the equation true | |
| Identity | an equation true for every value | |
| Contradiction | an equation true for no value | |
| Formula | an equation linking named quantities |
In software
The same words appear in code. A polynomial in a physics engine is stored as an array of coefficients, [−4, 0, 5] for . A compiler's parser splits a + b*c into terms joined by and factors joined by , which is precisely how it knows to multiply first. And a regression model's output is a sum of terms whose coefficients are the learned weights.
Exercises
Exercise 1: Name the parts
In , list the terms, the coefficients, the constant and the degree.
Answer
Terms , , 12; coefficients 8 and −1; constant 12; degree 3.
Solution
The terms are separated by and , and each keeps its sign. The coefficient of is −1 (the 1 is invisible). The highest exponent is 3, so the degree is 3.
Exercise 2: Like terms
Which of these are like terms with : (a) , (b) , (c) , (d) ?
Answer
(a) and (c)
Solution
Like terms need the same variables with the same powers: . (a) is . (c) is (multiplication order does not matter). (b) is and (d) is , so they differ.
Exercise 3: Term or factor?
Is the following simplification right? . If not, give the correct result.
Answer
No. The correct result is .
Solution
Only part of the numerator was divided. Every term must be divided, or equivalently factor first:
Check with : and , while .
Exercise 4: Degree with code
Use SymPy to find the total degree of .
Answer
5
Solution
The degrees of the terms are , 4 and . The highest is 5.
from sympy import symbols, Poly
x, y = symbols("x y")
print(Poly(3*x**2*y**3 - 2*x**4 + x*y, x, y).total_degree())5
Test yourself
What is the coefficient of the term in ?
- 0
- 1
- −1
- 2
What is the degree of ?
- 5
- 4
- 3
- 9
In , what are 7 and ?
- Terms
- Coefficients
- Constants
- Factors