Shape an expressionLesson 09 of 48 · 7 min
Cancel with the domain in view
Simplify a rational expression while retaining its original excluded inputs.
Maths refresher: Division by zero and removable holes
A fraction requires a nonzero denominator. Cancelling a common factor preserves equality only where that factor was nonzero.
At both expressions equal 3. At the original becomes 0/0, while the polynomial equals 2.
Cancelling a common factor can simplify a fraction. The domain is the set of inputs where the original fraction is defined. It excludes any input that makes the original denominator zero.
The code starts with divided by . Cancelling gives for every input in the original domain. The original is undefined at , where the cancelled polynomial evaluates to 2.
Python keeps the original denominator and uses solveset to find where it is zero for real . The hole setting chooses the excluded value and the input for the two evaluation results.
Does cancellation prove that the original fraction is defined at ?
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
Original denominator: x - 1
Cancelled formula: x + 1
Excluded input: {1}
Original at 1: Undefined
Cancelled formula at 1: 2
Read the starter result
Find Excluded input, Original at 1 and Cancelled formula at 1. Both formulas agree at every permitted input. Only the cancelled polynomial has a value at 1.
Edit and compare
Replace hole = 1 with hole = 2 in the editor. Select Run Python. Compare Excluded input, Original at 2 and Cancelled formula at 2. Which value does the polynomial supply, and why does the original rule still exclude that input?
Scope. SymPy expressions do not automatically retain a full history of removed domain restrictions.
Try a fresh case
A transformed expression agrees with the original except at a cancelled denominator zero. What should a report include?
Need a hint?
Hint 1
Inspect the denominator before cancellation.
Hint 2
Keep its zeros as exclusions.