Skip to content

RealSign ​

The sign of a real number x: -1, 0 or 1, as a function defined only on the reals.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageRealSign!
RealSign(x)-1, 0 or 1, according to the sign of the real number x.
Typed signatures
TypePackageApplies
(number) -> numberanalyticalways

Domain: Elementary functions

Details
  • Restricted to the reals, the sign is always decidable, so RealSign always resolves to an exact -1, 0 or 1 -- unlike native Sign, which stays symbolic at an exact expression it cannot immediately classify (e.g. Sign(2−2)\mathrm{Sign}(\sqrt2 - 2) stays unevaluated under plain evaluation).
  • A concretely complex argument is outside RealSign's domain and is left unevaluated.

Plot

Examples

Basic #
live ↗
InRealSign(−3)\mathrm{RealSign}(-3)Out−1-1
live ↗
InRealSign(0)\mathrm{RealSign}(0)Out00
live ↗
InRealSign(2.5)\mathrm{RealSign}(2.5)Out11

A positive number has sign 1

live ↗
InRealSign(2)\mathrm{RealSign}(2)Out11
Scope #

Threads element-wise over a list

live ↗
InRealSign([−2,0,5])\mathrm{RealSign}(\bigl\lbrack-2, 0, 5\bigr\rbrack)Out[−1,0,1]\bigl\lbrack-1, 0, 1\bigr\rbrack

Decides the sign of an exact numeric expression

live ↗
InRealSign(2−2)\mathrm{RealSign}(\sqrt{2}-2)Out−1-1

Entrywise sign of a matrix

live ↗
InRealSign([[12,−1],[0,−12]])\mathrm{RealSign}(\bigl\lbrack\bigl\lbrack\frac{1}{2}, -1\bigr\rbrack, \bigl\lbrack0, -\frac{1}{2}\bigr\rbrack\bigr\rbrack)Out[[1,−1],[0,−1]]\bigl\lbrack\bigl\lbrack1, -1\bigr\rbrack, \bigl\lbrack0, -1\bigr\rbrack\bigr\rbrack

As a matrix function it acts on eigenvalues, which changes the off-diagonal to −2-2

live ↗
InMatrixFunction(RealSign,[[12,−1],[0,−12]])\mathrm{MatrixFunction}(\mathrm{RealSign}, \bigl\lbrack\bigl\lbrack\frac{1}{2}, -1\bigr\rbrack, \bigl\lbrack0, -\frac{1}{2}\bigr\rbrack\bigr\rbrack)Out[[1,−2],[0,−1]]\bigl\lbrack\bigl\lbrack1, -2\bigr\rbrack, \bigl\lbrack0, -1\bigr\rbrack\bigr\rbrack

The symbol stays, as the sign depends on xx

live ↗
InPiecewiseExpand(RealSign(x))\mathrm{PiecewiseExpand}(\mathrm{RealSign}(x))OutRealSign(x)\mathrm{RealSign}(x)
Properties #

Real entries evaluate; the complex entry is left, since RealSign is real-only

live ↗
InRealSign([3,−5,2+5i])\mathrm{RealSign}(\bigl\lbrack3, -5, 2+5i\bigr\rbrack)Out[1,−1,RealSign(2+5i)]\bigl\lbrack1, -1, \mathrm{RealSign}(2+5i)\bigr\rbrack
About
Examples10
Checked againstWolfram Language 9 agree1 differ
CrosswalkWolfram Language