Expand algebraic expressions
expand rewrites an algebraic expression by multiplying out products and powers. It turns a compact form such as (x + 2) * (x - 2) into x^2 - 4, which can be easier to compare, differentiate, or collect into a polynomial.
When expansion helps
Expansion exposes individual terms. This is useful before applying derivative, comparing formulas with symbolicEqual, or solving a polynomial. It is the opposite direction from collecting a polynomial into factors; simplify can choose other reductions.
Use with care
Expansion can make a readable expression much larger, particularly for high powers or products of many sums. Keep a factored form when it better shows roots or avoids numerical cancellation. Expand symbolic expressions rather than expecting it to evaluate unknown names; use evaluate after assigning values. Check parentheses and operator precedence before expanding.