Shape an expressionLesson 07 of 48 · 7 min
Expand or factor?
Choose between a sum of terms and a product of factors.
Maths refresher: The distributive law
Multiplication distributes over addition. Factoring applies that relationship in reverse.
The two cross terms are and , so the coefficient of x is 1. The constant term is -6.
Expanding distributes products and powers into a sum. Factoring seeks a product representation. Both can represent the same polynomial, but each makes different structure visible.
A product can reveal zeros: if a product of real or complex numbers is zero, at least one factor is zero. A sum of powers is often convenient for reading coefficients or differentiating term by term. Choose the form from the task.
The example starts with a quadratic whose factors are small integers. Verify that expanding the factored result recovers the polynomial. Successful factorisation here is over rational coefficients; other domains or extensions can produce different factorizations.
Which form will make the zeros and easiest to see?
Write a prediction (optional)
Exact symbolic investigation
Select Run Python with the code unchanged.
Your saved draft is open. To use the published code, select Restore example in Tools. Use Recover draft to bring back your code.
Tools
About Python
Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗
Ctrl+Enter or ⌘+Enter runs Python.
Execution error
Technical error details
Your result
Python text output
Compare with the worked example
Executed from the published Python during the site build. Your own run appears above. Build environment ↗
Worked text output
Polynomial: x**2 + x - 6 Factored: (x - 2)*(x + 3) Expanded again: x**2 + x - 6 Identity check: 0
Read the starter result
Read Polynomial, Factored and Expanded again to check that both forms describe the same polynomial. The zero Identity check checks their exact difference.
Edit and compare
Replace polynomial = x**2+x-6 with polynomial = x**2+1. Select Run Python with factored = sp.factor(polynomial) unchanged. Then add , extension=sp.I inside that factor call and select Run Python again. Read Factored and Identity check. Which coefficient choices give new factors?
Scope. A factorisation depends on the coefficient domain. A polynomial irreducible over rationals may factor over complex numbers.
Try a fresh case
You want to read the coefficient of x cubed. Which representation is usually useful?
Need a hint?
Hint 1
A coefficient multiplies a power of the variable.
Hint 2
Write the expression as a sum of powers.