Skip to content

Expand ​

Expand out products and positive integer powers; for a hypercomplex operand, puts xx in blade normal form — the same result the multivector arithmetic already produces.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageExpand✓
Expand(x)expand out products and positive integer powers.
SageMathSR(x).expand()SymPyexpand(x)
Typed signatures
TypePackageApplies
(value) -> valuecombinatoricsreplaces hypercomplexalways
(value) -> valuecompute-enginealways
(value) -> valuehypercomplexreplaces compute-enginealways

Domain: Hypercomplex algebra

Examples

Basic #

Expand (x+1)2(x+1)^2 into x2+2x+1x^2 + 2x + 1

live ↗
InExpand((x+1)2)\mathrm{Expand}((x+1)^2)Outx2+2x+1x^2+2x+1

Expand (x+1)(x−1)(x+1)(x-1) into the difference of squares

live ↗
InExpand((x+1)(x−1))\mathrm{Expand}((x+1)(x-1))Outx2−1x^2-1

Multiplies out a product of two binomials

live ↗
InExpand((x+3)(x+2))\mathrm{Expand}((x+3)(x+2))Outx2+5x+6x^2+5x+6

A product of three polynomial factors collapses to one degree-10 polynomial

live ↗
InExpand((1+x)3(5x2+1)(x5+1))\mathrm{Expand}((1+x)^3(5x^2+1)(x^5+1))Out5x10+15x9+16x8+8x7+3x6+6x5+15x4+16x3+8x2+3x+15x^{10}+15x^9+16x^8+8x^7+3x^6+6x^5+15x^4+16x^3+8x^2+3x+1

The pure fifth powers cancel, leaving only mixed terms

live ↗
InExpand((x+y)5−(x5+y5))\mathrm{Expand}((x+y)^5-(x^5+y^5))Out5yx4+5xy4+10y3x2+10x3y25yx^4+5xy^4+10y^3x^2+10x^3y^2
Scope #

Expand (x+y)3(x+y)^3, a two-variable binomial power

live ↗
InExpand((x+y)3)\mathrm{Expand}((x+y)^3)Outx3+y3+3yx2+3xy2x^3+y^3+3yx^2+3xy^2

A product of conjugates squared: (x2−y2)2(x^2-y^2)^2 expanded

live ↗
InExpand((x+y)2(x−y)2)\mathrm{Expand}((x+y)^2(x-y)^2)Outx4+y4−2x2y2x^4+y^4-2x^2y^2

A negative power in the denominator is kept, only the numerator is expanded

live ↗
InExpand((x+y)2(x−y)2)\mathrm{Expand}(\frac{(x+y)^2}{(x-y)^2})Outx2(x−y)2+y2(x−y)2+2xy(x−y)2\frac{x^2}{(x-y)^2}+\frac{y^2}{(x-y)^2}+\frac{2xy}{(x-y)^2}

Expands around non-polynomial atoms like sin⁡x\sin x

live ↗
InExpand((sin⁡(x)+cos⁡(x))2)\mathrm{Expand}((\sin(x)+\cos(x))^2)Outsin⁡(x)2+cos⁡(x)2+2sin⁡(x)cos⁡(x)\sin(x)^2+\cos(x)^2+2\sin(x)\cos(x)

Under a root the base is not expanded, only reordered

live ↗
InExpand((1+x)2)\mathrm{Expand}(\sqrt{(1+x)^2})Out(x+1)2\sqrt{(x+1)^2}

Same shape with a different denominator: terms are split over it

live ↗
InExpand((x+y)2(z+y)2)\mathrm{Expand}(\frac{(x+y)^2}{(z+y)^2})Outx2(y+z)2+y2(y+z)2+2xy(y+z)2\frac{x^2}{(y+z)^2}+\frac{y^2}{(y+z)^2}+\frac{2xy}{(y+z)^2}

The binomial theorem row for n=5n=5 as an identity

live ↗
Inx5+5x4+10x3+10x2+5x+1=Expand((x+1)5)x^5+5x^4+10x^3+10x^2+5x+1=\mathrm{Expand}((x+1)^5)OutTrue\mathrm{True}
live ↗
InExpand((x+i)(x−i))\mathrm{Expand}((x+i)(x-i))Outx2+1x^2+1
live ↗
InExpand((xs+2e−x)3)\mathrm{Expand}((x^{s}+2e^{-x})^3)Outx3s+6e−xx2s+12e−2xxs+8e−3xx^{3s}+6e^{-x}x^{2s}+12e^{-2x}x^{s}+8e^{-3x}
Applications #

Four factors collapse to (x2−1)2(x^2-1)^2

live ↗
InExpand((1−x)(−x−1)(1−x)(−x−1))\mathrm{Expand}((1-x)(-x-1)(1-x)(-x-1))Outx4−2x2+1x^4-2x^2+1
Properties #

Multiple variables expand and collect by powers of xx

live ↗
InExpand((1+x+y)(2−x)3)\mathrm{Expand}((1+x+y)(2-x)^3)Out−x4−yx3+5x3+6yx2−6x2−12xy−4x+8y+8-x^4-yx^3+5x^3+6yx^2-6x^2-12xy-4x+8y+8

Coefficients of (x+1)(x+2)(x+3)(x+1)(x+2)(x+3) are Stirling numbers of the first kind

live ↗
InExpand((1+x)(2+x)(3+x))\mathrm{Expand}((1+x)(2+x)(3+x))Outx3+6x2+11x+6x^3+6x^2+11x+6
live ↗
InExpand(∏i=6(x+i))\mathrm{Expand}(\prod_{i=6}(x+i))Outx6+21x5+175x4+735x3+1 624x2+1 764x+720x^6+21x^5+175x^4+735x^3+1\,624x^2+1\,764x+720
live ↗
InExpand(∏k=6(x+k))\mathrm{Expand}(\prod_{k=6}(x+k))Outx6+21x5+175x4+735x3+1 624x2+1 764x+720x^6+21x^5+175x^4+735x^3+1\,624x^2+1\,764x+720
About
Examples19
Checked againstWolfram Language 19 agreeSageMath 17 agree1 differSymPy 18 agree1 differ
CrosswalkWolfram LanguageSageMathSymPy

Implementation

mappedsagepackages/oracle/src/mappings.ts
mappedsympypackages/oracle/src/mappings.ts

See also: NonCommutativeMultiply, Basis