Skip to content

Sqrt ​

The principal square root of x: x\sqrt{x}.

✓ checked against that system · ! checked, with disagreements (hover a chip)WikipediaSquare rootMathWorldSquareRootWikidataQ134237Britannicatopic/square-rootFungrimSqrtWolfram LanguageSqrt!
Sqrt(x)the principal square root x=x1/2\sqrt{x} = x^{1/2}.
SageMathsqrt(x)✓SymPysqrt(x)mpmathsqrt(x)Rustsqrt(x)
Typed signatures
TypePackageApplies
(complex | infinity) -> complex | infinityanalyticreplaces compute-engineon Around, CenteredInterval, Interval
(complex | infinity) -> complex | infinitycompute-enginealways

Domain: Arithmetic

Details
  • The principal square root: x=x1/2\sqrt{x} = x^{1/2}. See Root for other roots and Square for the inverse operation.
  • Evaluates exactly only when the radicand is a perfect square (or a ratio of perfect squares); otherwise it stays in symbolic surd form, like 2\sqrt{2}.
  • A negative radicand gives an imaginary result, −a=ia\sqrt{-a} = i\sqrt{a} for a>0a>0 -- but only reduces to an exact Complex number when aa itself is a perfect square.
  • 0=0\sqrt{0} = 0.
  • compute-engine's Sqrt is a special case of the more general Root: Root(x,2)\mathrm{Root}(x, 2) canonicalizes to Sqrt(x)\mathrm{Sqrt}(x).

Examples

8 more kept as data, checked against the oracles
Basic #
live ↗
In16\sqrt{16}Out44

Stays symbolic when the radicand isn't a perfect square

live ↗
In2\sqrt{2}Out2\sqrt{2}
live ↗
In49\sqrt{\frac{4}{9}}Out23\frac{2}{3}
live ↗
In0\sqrt{0}Out00

A perfect square radicand evaluates exactly, even when negative

live ↗
In−4\sqrt{-4}Out2i2i

An approximate number gives an approximate root

live ↗
In3.5\sqrt{3.5}Out1.870 828 693 386 970 692 791.870\,828\,693\,386\,970\,692\,79

Pulls perfect-square factors out of the radical

live ↗
In200\sqrt{200}Out10210\sqrt{2}
live ↗
In−25\sqrt{-25}Out5i5i
Scope #
live ↗
In8\sqrt{8}Out222\sqrt{2}

Rationalizes the denominator

live ↗
In12\sqrt{\frac{1}{2}}Out22\frac{\sqrt{2}}{2}
live ↗
In125\sqrt{\frac{12}{5}}Out2155\frac{2\sqrt{15}}{5}
live ↗
In−2.5\sqrt{-2.5}Out1.581 138 830 084 189 8i1.581\,138\,830\,084\,189\,8i

An exact complex square: (2+i)2=3+4i(2+i)^2 = 3+4i

live ↗
In3+4i\sqrt{3+4i}Out2+i2+i
live ↗
In∞\sqrt{∞}Out∞∞

Sqrt(-Infinity) = i Infinity, the principal branch's direction as the radicand goes to -Infinity (DLMF 4.2.2)

live ↗
In−∞\sqrt{-∞}Out∞~\tilde∞

Known value · Wolfram MathematicalFunctionData, Sqrt

Threads element-wise over a list

live ↗
In[1,4,9]\sqrt{\bigl\lbrack1, 4, 9\bigr\rbrack}Out[1,2,3]\bigl\lbrack1, 2, 3\bigr\rbrack

Threads over a matrix entry by entry -- this is not the matrix square root

live ↗
In[[12,−1],[0,12]]\sqrt{\bigl\lbrack\bigl\lbrack\frac{1}{2}, -1\bigr\rbrack, \bigl\lbrack0, \frac{1}{2}\bigr\rbrack\bigr\rbrack}Out[[22,i],[0,22]]\bigl\lbrack\bigl\lbrack\frac{\sqrt{2}}{2}, i\bigr\rbrack, \bigl\lbrack0, \frac{\sqrt{2}}{2}\bigr\rbrack\bigr\rbrack

Interval arithmetic: \sqrt{} is increasing, so [1,8]=[1,22]\sqrt{[1,8]} = [1, 2\sqrt2]

live ↗
InInterval(1,8)\sqrt{\mathrm{Interval}(1, 8)}OutInterval(1,22)\mathrm{Interval}(1, 2\sqrt{2})

To 45 significant digits, every one correctly rounded

live ↗
InN(2,45)N(\sqrt{2}, 45)Out1.414 213 562 373 095 048 801 688 724 209 698 078 569 671 881.414\,213\,562\,373\,095\,048\,801\,688\,724\,209\,698\,078\,569\,671\,88
Applications #

The Pythagorean hypotenuse of a 3-4-5 triangle

live ↗
In32+42\sqrt{3^2+4^2}Out55
Properties #

(x)2=x(\sqrt{x})^2 = x for a perfect square. See Square

live ↗
In162=16\sqrt{16}^2=16OutTrue\mathrm{True}

x=x1/2\sqrt{x} = x^{1/2}

live ↗
In16=16\sqrt{16}=\sqrt{16}OutTrue\mathrm{True}

(x)2=x(\sqrt{x})^2 = x for every x

live ↗
Inx2\sqrt{x}^2Outxx
Possible issues #

Negative but not a perfect square: stays symbolic rather than reducing to an exact complex value

live ↗
In−2\sqrt{-2}Out−2\sqrt{-2}

A negative rational still evaluates exactly when both numerator and denominator are perfect squares

live ↗
In−49\sqrt{-\frac{4}{9}}Out23i\frac{2}{3}i

x2\sqrt{x^2} is not simplified to x, which would be wrong for negative x

live ↗
Inx2\sqrt{x^2}Outx2\sqrt{x^2}

...at x=−1x = -1, x2=1\sqrt{x^2} = 1, not −1-1

live ↗
In(−1)2\sqrt{(-1)^2}Out11

ab=ab\sqrt{a}\sqrt{b} = \sqrt{ab} fails for negative a and b: −1−1=−1\sqrt{-1}\sqrt{-1} = -1...

live ↗
In−1−1\sqrt{-1}\sqrt{-1}Out−1-1

...while (−1)(−1)=1\sqrt{(-1)(-1)} = 1

live ↗
In1\sqrt{1}Out11
About
Examples37
Checked againstWolfram Language 36 agree1 differSageMath 33 agreeSymPy 35 agree1 differmpmath 31 agree1 differRust 13 agree12 differ1 unevaluated2 error
CrosswalkWikipediaMathWorldWikidataBritannicaFungrimWolfram LanguageSageMathSymPympmathRust

Implementation

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

See also: Root, Square