Reciprocal: Difference between revisions
Jump to navigation
Jump to search
m (It is monadic, not dyadic) |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Built-in|Reciprocal|÷}} is a [[monadic]] [[scalar function]] which gives the [[wikipedia:Multiplicative inverse|multiplicative inverse]] of a real or [[complex]] number. Reciprocal shares the [[glyph]] < | {{Built-in|Reciprocal|÷}} is a [[monadic]] [[scalar function]] which gives the [[wikipedia:Multiplicative inverse|multiplicative inverse]] of a real or [[complex]] number. Reciprocal shares the [[glyph]] <syntaxhighlight lang=apl inline>÷</syntaxhighlight> with the dyadic arithmetic function [[Divide]]. | ||
== Examples == | == Examples == | ||
< | <syntaxhighlight lang=apl> | ||
÷1 2 3 4 5 | ÷1 2 3 4 5 | ||
1 0.5 0.3333333333 0.25 0.2 | 1 0.5 0.3333333333 0.25 0.2 | ||
Line 17: | Line 17: | ||
÷0 | ÷0 | ||
0 | 0 | ||
</ | </syntaxhighlight> | ||
== Properties == | == Properties == | ||
The reciprocal of any real or complex number is equal to 1 [[divide]]d by that number. Therefore the monadic <syntaxhighlight lang=apl inline>÷</syntaxhighlight> can be seen as dyadic <syntaxhighlight lang=apl inline>÷</syntaxhighlight> with default left argument of 1. This applies even to the reciprocal of 0; <syntaxhighlight lang=apl inline>÷0</syntaxhighlight> and <syntaxhighlight lang=apl inline>1÷0</syntaxhighlight> show identical behavior for both <syntaxhighlight lang=apl inline>⎕DIV←0</syntaxhighlight> (raising [[DOMAIN ERROR]]) and <syntaxhighlight lang=apl inline>⎕DIV←1</syntaxhighlight> (returning 0). | |||
< | <syntaxhighlight lang=apl> | ||
÷1 2 3 4 5 | ÷1 2 3 4 5 | ||
1 0.5 0.3333333333 0.25 0.2 | 1 0.5 0.3333333333 0.25 0.2 | ||
Line 29: | Line 29: | ||
1÷1 2 3 4 5 | 1÷1 2 3 4 5 | ||
1 0.5 0.3333333333 0.25 0.2 | 1 0.5 0.3333333333 0.25 0.2 | ||
</ | </syntaxhighlight> | ||
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. | 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. | ||
< | <syntaxhighlight lang=apl> | ||
(×∘÷ ≡ +∘×)1 2 3 ¯2 0.5 1J2 | (×∘÷ ≡ +∘×)1 2 3 ¯2 0.5 1J2 | ||
1 | 1 | ||
Line 39: | Line 39: | ||
(|∘÷ ≡ ÷∘|)1 2 3 ¯2 0.5 1J2 | (|∘÷ ≡ ÷∘|)1 2 3 ¯2 0.5 1J2 | ||
1 | 1 | ||
</ | </syntaxhighlight>{{Works in|[[Dyalog APL]]}} | ||
== See also == | |||
* [[Times]] | |||
* [[Negate]] | |||
* [[Root]] | |||
== External links == | == External links == | ||
=== Documentation === | === Documentation === | ||
* [ | * [https://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] | ||
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#basic-arithmetic BQN] | |||
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]] | {{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]] |
Latest revision as of 21:56, 10 September 2022
÷
|
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 ∧ ⎕DIV←1 ⍝ 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 ⎕DIV←0
(raising DOMAIN ERROR) and ⎕DIV←1
(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