Difference between revisions of "Reciprocal"

From APL Wiki
Jump to navigation Jump to search
(Created page with "{{Built-in|Reciprocal|÷}} is a monadic scalar function which gives the multiplicative inverse of a real or complex number. Re...")
 
 
(2 intermediate revisions by 2 users not shown)
Line 21: Line 21:
 
== Properties ==
 
== Properties ==
  
Reciprocal of any real or complex number is equal to 1 divided by that number. Therefore the monadic <source lang=apl inline>÷</source> can be seen as dyadic <source lang=apl inline>÷</source> with default left argument of 1. This applies even to the reciprocal of 0; <source lang=apl inline>÷0</source> and <source lang=apl inline>1÷0</source> show identical behavior for both <source lang=apl inline>⎕DIV←0</source> (raising [[DOMAIN ERROR]]) and <source lang=apl inline>⎕DIV←1</source> (returning 0).
+
The reciprocal of any real or complex number is equal to 1 [[divide]]d by that number. Therefore the monadic <source lang=apl inline>÷</source> can be seen as dyadic <source lang=apl inline>÷</source> with default left argument of 1. This applies even to the reciprocal of 0; <source lang=apl inline>÷0</source> and <source lang=apl inline>1÷0</source> show identical behavior for both <source lang=apl inline>⎕DIV←0</source> (raising [[DOMAIN ERROR]]) and <source lang=apl inline>⎕DIV←1</source> (returning 0).
  
 
<source lang=apl>
 
<source lang=apl>
Line 41: Line 41:
 
</source>{{Works in|[[Dyalog APL]]}}
 
</source>{{Works in|[[Dyalog APL]]}}
  
 +
== See also ==
 +
* [[Times]]
 +
* [[Negate]]
 +
* [[Root]]
 
== External links ==
 
== External links ==
  
Line 47: Line 51:
 
* [http://help.dyalog.com/17.1/#Language/Primitive%20Functions/Reciprocal.htm Dyalog]
 
* [http://help.dyalog.com/17.1/#Language/Primitive%20Functions/Reciprocal.htm Dyalog]
 
* [https://www.jsoftware.com/help/dictionary/d130.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/percent NuVoc]
 
* [https://www.jsoftware.com/help/dictionary/d130.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/percent NuVoc]
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar dyadic functions]]
+
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]]

Latest revision as of 06:50, 9 July 2020

÷

Reciprocal (÷) is a monadic scalar function which gives the multiplicative inverse of a real or complex number. Reciprocal shares the glyph ÷ with the dyadic arithmetic function Divide.

Examples

      ÷1 2 3 4 5
1 0.5 0.3333333333 0.25 0.2
 
      ÷¯2 0.5 1J2
¯0.5 2 0.2J¯0.4

      ÷0
DOMAIN ERROR: Divide by zero
 ÷0                         
 
 
      ⎕DIV1  ⍝ this sets division by 0 to always return 0
      ÷0
0

Properties

The reciprocal of any real or complex number is equal to 1 divided by that number. Therefore the monadic ÷ can be seen as dyadic ÷ with default left argument of 1. This applies even to the reciprocal of 0; ÷0 and 1÷0 show identical behavior for both ⎕DIV0 (raising DOMAIN ERROR) and ⎕DIV1 (returning 0).

      ÷1 2 3 4 5
1 0.5 0.3333333333 0.25 0.2

      1÷1 2 3 4 5
1 0.5 0.3333333333 0.25 0.2

For any non-zero real or complex numbers, the signum of reciprocal is equal to the conjugate of signum, and the magnitude of reciprocal is equal to the reciprocal of magnitude.

      (×÷  +×)1 2 3 ¯2 0.5 1J2
1

      (|÷  ÷|)1 2 3 ¯2 0.5 1J2
1
Works in: Dyalog APL

See also

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