Skip to content
AgileLogics
6 min read

Symbolic Algebra

Prerequisites: Rules and replacement

Symbolic manipulation is what the Wolfram Language is famous for. Make sure the symbols you use have no values (Clear[x, y, a, b]).

Expanding and factoring

Expand[(x + 1)^3]
Factor[x^3 - 1]
Factor[x^2 - 5 x + 6]
Collect[a x + b x + c, x]
Coefficient[(1 + x)^3, x, 2]
1 + 3 x + 3 x^2 + x^3
(-1 + x) (1 + x + x^2)
(-3 + x) (-2 + x)
c + (a + b) x
3

Results always come back in the language's standard order — constants first, lower powers before higher ones.

Simplifying

Simplify[(x^2 - 1)/(x - 1)]
Simplify[Sin[x]^2 + Cos[x]^2]
Together[1/x + 1/y]
Apart[1/(x^2 - 1)]
1 + x
1
(x + y)/(x y)
1/(2 (-1 + x)) - 1/(2 (1 + x))
  • Simplify searches for the simplest equivalent form; FullSimplify tries harder (and takes longer).
  • Together combines fractions; Apart splits them into partial fractions.

Assumptions

Simplify[Sqrt[x^2]]
Simplify[Sqrt[x^2], x > 0]
Simplify[Sqrt[x^2], Element[x, Reals]]
Sqrt[x^2]
x
Abs[x]

Symbols are treated as complex numbers unless you say otherwise, so Sqrt[x^2] can't simplify without knowing more. Give assumptions as a second argument, or wrap code in Assuming[x > 0, ...].

Trigonometry

TrigExpand[Sin[2 x]]
TrigReduce[2 Sin[x] Cos[x]]
2 Cos[x] Sin[x]
Sin[2 x]

Practice

Factor x^4 - 16, then expand the result back and check it matches.

Show solution
Factor[x^4 - 16]
Expand[%]
(-2 + x) (2 + x) (4 + x^2)
-16 + x^4