Skip to content

Square ​

The second power of x: x2x^2.

Square(x)the second power x2x^2.
Juliaenumeratio_pow(x, 2)Rustpower(x, n(2))
Typed signatures
TypePackageApplies
(number) -> numbercompute-enginealways

Domain: Arithmetic

Details
  • Canonicalizes to x2x^2: Square(x)\mathrm{Square}(x) and Power(x,2)\mathrm{Power}(x, 2) are the same expression. See Sqrt.
  • Even function: (−x)2=x2(-x)^2 = x^2, so the sign of the input is lost.
  • Always non-negative for real x; for a complex number it need not be, e.g. (1+i)2=2i(1+i)^2 = 2i.
  • Threads element-wise over a list.
  • Square is purely a convenience head: it canonicalizes away to x2x^2 (Power).

Plot

Examples

Basic #
live ↗
In525^2Out2525

Same result for x and -x

live ↗
In(−5)2(-5)^2Out2525
live ↗
In(23)2(\frac{2}{3})^2Out49\frac{4}{9}

Canonicalizes to x2x^2

live ↗
Inx2x^2Outx2x^2

Threads element-wise over a list

live ↗
In[2,3,−4]2\bigl\lbrack2, 3, -4\bigr\rbrack^2Out[4,9,16]\bigl\lbrack4, 9, 16\bigr\rbrack
Applications #

The area of a 3×3 square tile

live ↗
In323^2Out99
Properties #

Even function: (−x)2=x2(-x)^2 = x^2

live ↗
In(−5)2=52(-5)^2=5^2OutTrue\mathrm{True}

(1+i)2=2i(1+i)^2 = 2i -- squaring a complex number needn't stay real

live ↗
In(1+i)2=2i(1+i)^2=2iOutTrue\mathrm{True}
Possible issues #

Infinity squared stays infinite rather than erroring

live ↗
In∞2∞^2Out∞∞
About
Examples9
Checked againstWolfram Language 9 agreeSageMath 8 agree1 errorSymPy 8 agree1 errormpmath 6 agree1 errorJulia 7 agree1 errorRust 6 agree
CrosswalkWikipediaWikidataJuliaRust

Implementation

mappedwolframpackages/oracle/src/mappings.ts
mappedsympypackages/oracle/src/mappings.ts
mappedmpmathpackages/oracle/src/mappings.ts
mappedsagepackages/oracle/src/mappings.ts
mappedjuliapackages/oracle/src/mappings.ts
mappedrustpackages/oracle/src/mappings.ts

See also: Sqrt, Root