Difference between revisions of "Magnitude"

From APL Wiki
Jump to navigation Jump to search
m
Line 1: Line 1:
{{Built-in|Magnitude|<nowiki>|</nowiki>}} or '''Absolute Value''' is a [[monadic]] [[scalar function]] which gives the [[wikipedia:Absolute value|absolute value]] of a real or [[complex]] number. Magnitude shares the [[glyph]] <source lang=apl inline>|</source> with the dyadic arithmetic function [[Residue]].
+
{{Built-in|Magnitude|<nowiki>|</nowiki>}}, or '''Absolute Value''', is a [[monadic]] [[scalar function]] which gives the [[wikipedia:Absolute value|absolute value]] of a real or [[complex]] number. Magnitude shares the [[glyph]] <source lang=apl inline>|</source> with the dyadic arithmetic function [[Residue]].
  
 
== Examples ==
 
== Examples ==

Revision as of 14:14, 29 May 2020

|

Magnitude (|), or Absolute Value, is a monadic scalar function which gives the absolute value of a real or complex number. Magnitude shares the glyph | with the dyadic arithmetic function Residue.

Examples

      |0 1 2 ¯1 ¯2
0 1 2 1 2
 
      |0J2 ¯3J¯4
2 5

Properties

The magnitude of any number is a non-negative real number.

For real numbers, the magnitude equals the original number times (or divided by, for non-zero numbers) its sign.

      v0 1E¯100 20 1E300 ¯1E¯100 ¯20 ¯1E300
      (|v)v××v
1
      (|v)=v÷×v
0 1 1 1 1 1 1

For complex numbers, the magnitude is defined as the Euclidean distance from the number 0 on the complex plane.

      Dist{0.5*+.×9 11} ⍝ Square root of square sum of real and imaginary parts
      Dist¨ 0 1J2 ¯3J4
0 2.236067977 5
      |0 1J2 ¯3J4
0 2.236067977 5
Works in: Dyalog APL

Any real or complex number is equal to the product of its signum and magnitude.

      (  ××|) 0 1 1E¯300 ¯2.5 0J3.5 ¯3J¯4
1
Works in: Dyalog APL

External links

Documentation

APL built-ins [edit]
Primitive functions
Scalar
Monadic ConjugateNegateSignumReciprocalMagnitudeExponentialNatural LogarithmFloorCeilingFactorialNotPi TimesRollTypeImaginarySquare Root
Dyadic AddSubtractTimesDivideResiduePowerLogarithmMinimumMaximumBinomialComparison functionsBoolean functions (And, Or, Nand, Nor) ∙ GCDLCMCircularComplexRoot
Non-Scalar
Structural ShapeReshapeTallyDepthRavelEnlistTableCatenateReverseRotateTransposeRazeMixSplitEncloseNestCut (K)PairLinkPartitioned EnclosePartition
Selection FirstPickTakeDropUniqueIdentitySelectReplicateExpandSet functions (IntersectionUnionWithout) ∙ Bracket indexingIndex
Selector Index generatorGradeIndex OfInterval IndexIndicesDeal
Computational MatchNot MatchMembershipFindNub SieveEncodeDecodeMatrix InverseMatrix DivideFormatExecuteMaterialiseRange
Primitive operators Monadic EachCommuteConstantReplicateExpandReduceWindowed ReduceScanOuter ProductKeyI-beamSpawnFunction axis
Dyadic BindCompositions (Compose, Reverse Compose, Beside, Atop, Over) ∙ Inner ProductPowerAtUnderRankDepthVariantStencilCut (J)
Quad names
Arrays Index originMigration levelAtomic vector
Functions Case convertUnicode convert
Operators SearchReplace