Skip to content

RealAbs ​

The absolute value of a real number x, as a function defined only on the reals.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageRealAbs✓
RealAbs(x)the absolute value of the real number x.
Juliaenumeratio_ball(abs, x)
Typed signatures
TypePackageApplies
(number) -> numberanalyticalways

Domain: Elementary functions

Details
  • Agrees with native Abs on every real x -- RealAbs exists so a plot or a domain check can say "real only" and mean it, the way Wolfram's does.
  • A concretely complex argument is outside RealAbs's domain and is left unevaluated -- unlike Abs, which is complex-valued (the modulus).

Plot

Examples

Basic #

The absolute value of a real number

live ↗
InRealAbs(−2.5)\mathrm{RealAbs}(-2.5)Out2.52.5
live ↗
InRealAbs(−72)\mathrm{RealAbs}(-\frac{7}{2})Out72\frac{7}{2}

A positive number is unchanged

live ↗
InRealAbs(2)\mathrm{RealAbs}(2)Out22
live ↗
IndRealAbs(x)dx\frac{\mathrm{d}\mathrm{RealAbs}(x)}{\mathrm{d}x}Outsgn(x)\mathrm{sgn}(x)
Scope #

Threads element-wise over a list

live ↗
InRealAbs([−1,2,−3])\mathrm{RealAbs}(\bigl\lbrack-1, 2, -3\bigr\rbrack)Out[1,2,3]\bigl\lbrack1, 2, 3\bigr\rbrack

Exact numeric arguments

live ↗
InRealAbs(−π)\mathrm{RealAbs}(-π)Outππ

A 50-digit value of ∣π−G∣|\pi - G|, with GG Catalan's constant

live ↗
InN(RealAbs(π−G⁡),50)N(\mathrm{RealAbs}(π-\operatorname{G}), 50)Out2.225 627 059 412 574 223 408 039 868 347 118 773 423 020 025 093 42.225\,627\,059\,412\,574\,223\,408\,039\,868\,347\,118\,773\,423\,020\,025\,093\,4

Applied entrywise to a matrix

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

As a matrix function it acts on eigenvalues, not entries, so the off-diagonal becomes 0

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

Interval arithmetic gives [0,5][0,5] from [−5,3][-5,3]

live ↗
InRealAbs(Interval(−5,3))\mathrm{RealAbs}(\mathrm{Interval}(-5, 3))OutInterval(0,5)\mathrm{Interval}(0, 5)

Zero stays zero

live ↗
InRealAbs(0)\mathrm{RealAbs}(0)Out00

Infinity maps to infinity

live ↗
InRealAbs(∞)\mathrm{RealAbs}(∞)Out∞∞

Negative infinity also gives positive infinity

live ↗
InRealAbs(−∞)\mathrm{RealAbs}(-∞)Out∞∞

Rewrites to the ordinary absolute value

live ↗
InPiecewiseExpand(RealAbs(x))\mathrm{PiecewiseExpand}(\mathrm{RealAbs}(x))Out∣x∣\vert x\vert
Properties #

Agrees with Abs on the reals

live ↗
InRealAbs(−5)=∣−5∣\mathrm{RealAbs}(-5)=\vert-5\vertOutTrue\mathrm{True}
About
Examples15
Checked againstWolfram Language 15 agreeJulia 8 agree2 error
CrosswalkWolfram LanguageJulia

Implementation

mappedjuliapackages/oracle/src/mappings.ts