Conjugate: Difference between revisions
m (→Mathematics: WP link style) |
(History) |
||
(7 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Built-in|Conjugate|+}} is a [[monadic]] [[scalar function]] which negates the imaginary component of a [[complex]] argument. Because many APLs do not have a dedicated [[Identity]] function, but also do not support complex numbers, Conjugate is often used to return the argument unchanged. This usage is discouraged in modern APLs in favor of the Identity function (usually < | {{Built-in|Conjugate|+}} is a [[monadic]] [[scalar function]] which negates the imaginary component of a [[complex]] argument. Because many APLs do not have a dedicated [[Identity]] function, but also do not support complex numbers, Conjugate is often used to return the argument unchanged. This usage is discouraged in modern APLs in favor of the Identity function (usually <syntaxhighlight lang=apl inline>⊢</syntaxhighlight>). Conjugate shares the glyph <syntaxhighlight lang=apl inline>+</syntaxhighlight> with [[Add]]. | ||
== Examples == | == Examples == | ||
Conjugate leaves real numbers unchanged but negates the imaginary part of complex numbers. | Conjugate leaves real numbers unchanged but negates the imaginary part of complex numbers. | ||
< | <syntaxhighlight lang=apl> | ||
+ 0 2 ¯1.1 1E300 ¯200 | + 0 2 ¯1.1 1E300 ¯200 | ||
0 2 ¯1.1 1E300 ¯200 | 0 2 ¯1.1 1E300 ¯200 | ||
+ 2J3 ¯4J¯3 ¯12 1.5J1.5 | + 2J3 ¯4J¯3 ¯12 1.5J1.5 | ||
2J¯3 ¯4J3 ¯12 1.5J¯1.5 | 2J¯3 ¯4J3 ¯12 1.5J¯1.5 | ||
</ | </syntaxhighlight> | ||
== As identity function == | == As identity function == | ||
In early APLs Conjugate was frequently used to return the argument unchanged, for example to display a [[shy]] result or break up [[stranding]]: | In early APLs Conjugate was frequently used to return the argument unchanged, for example to display a [[shy]] result or break up [[stranding]]: | ||
< | <syntaxhighlight lang=apl> | ||
+a←2 3 | +a←2 3 | ||
2 3 | 2 3 | ||
*∘2⍣3 +a | *∘2⍣3 +a | ||
256 6561 | 256 6561 | ||
</ | </syntaxhighlight> | ||
Sometimes the name "Identity" was even used for < | Sometimes the name "Identity" was even used for <syntaxhighlight lang=apl inline>+</syntaxhighlight>. Although this usage is becoming rare among new APLers, it may still affect the behavior of Conjugate. For instance, in [[Dyalog APL]], Conjugate will allow a non-numeric argument and return it unchanged even though other monadic scalar functions give a [[DOMAIN ERROR]]: | ||
< | <syntaxhighlight lang=apl> | ||
+ ⎕NULL | + ⎕NULL | ||
[Null] | [Null] | ||
Line 28: | Line 28: | ||
-⎕NULL | -⎕NULL | ||
∧ | ∧ | ||
</ | </syntaxhighlight> | ||
Note that other APLs, e.g. [[APLX]] (which does not support complex numbers) and [[APL2]] do not allow applying Conjugate to non-numeric data. | |||
== Properties == | == Properties == | ||
Line 34: | Line 35: | ||
Like [[Negate]], Conjugate is its own [[Inverse]]. | Like [[Negate]], Conjugate is its own [[Inverse]]. | ||
The conjugate of a number is proportional to (that is, a real multiple of) its [[Reciprocal]]. Specifically, since for any complex number < | The conjugate of a number is proportional to (that is, a real multiple of) its [[Reciprocal]]. Specifically, since for any complex number <syntaxhighlight lang=apl inline>z</syntaxhighlight>, <syntaxhighlight lang=apl inline>z×+z</syntaxhighlight> {{←→}} <syntaxhighlight lang=apl inline>(+z)×z</syntaxhighlight> is a real number (the square of the [[Magnitude]] of <syntaxhighlight lang=apl inline>z</syntaxhighlight>), we have <syntaxhighlight lang=apl inline>z×((+z)÷z×+z)</syntaxhighlight> {{←→}} <syntaxhighlight lang=apl inline>1</syntaxhighlight>, so by definition <syntaxhighlight lang=apl inline>(+z)÷z×+z</syntaxhighlight> is <syntaxhighlight lang=apl inline>÷z</syntaxhighlight>. If <syntaxhighlight lang=apl inline>z</syntaxhighlight> is a unit complex number (for instance the result of [[Signum]]), then <syntaxhighlight lang=apl inline>+z</syntaxhighlight> {{←→}} <syntaxhighlight lang=apl inline>÷z</syntaxhighlight>. | ||
== Hypercomplex numbers == | == Hypercomplex numbers == | ||
The conjugate of a hypercomplex number (a quaternion or octonion) negates ''all'' imaginary components, that is, every component but the real part. Somewhat surprisingly, this maintains the property that < | The conjugate of a hypercomplex number (a quaternion or octonion) negates ''all'' imaginary components, that is, every component but the real part. Somewhat surprisingly, this maintains the property that <syntaxhighlight lang=apl inline>z×+z</syntaxhighlight> {{←→}} <syntaxhighlight lang=apl inline>(+z)×z</syntaxhighlight> is a real number. Therefore the conjugate can be used to define the [[reciprocal]] of a complex number using only real division (dividing a hypercomplex number by a real number divides each component by that numer). | ||
== Numerical precision == | == Numerical precision == | ||
Like [[Negate]], Conjugate almost never suffers issues with numerical precision. This is because negating a component of a complex number is exact in all common number systems. | Like [[Negate]], Conjugate almost never suffers issues with numerical precision. This is because negating a component of a complex number is exact in all common number systems. | ||
== History == | |||
In early APLs, which did not support complex numbers, monadic <syntaxhighlight lang=apl inline>+</syntaxhighlight> returned its argument unchanged; however, this was not initially considered as a restriction of the complex conjugate to real numbers. In fact, [[Phil Abrams]]' report on [[IVSYS/7090]] defined <syntaxhighlight lang=apl inline>+A</syntaxhighlight> to be <syntaxhighlight lang=apl inline>0+A</syntaxhighlight>, implying that the function should extend to the identity on complex numbers as well. The extension to complex conjugate was included in a 1977 proposal by Paul Penfield,<ref>Paul Penfield. [https://dl.acm.org/doi/full/10.1145/586003.586007 Notation for complex "part" functions]. [[APL Quote Quad]] Volume 8, Issue 1. 1977-09.</ref> who noted that it had already appeared in a 1975 IBM publication documenting APL.<ref>[[IBM]]. [https://archive.org/details/bitsavers_ibmaplGC2675_6717824/mode/2up APL Language]. GC26-3847-0. 1975-03.</ref> Penfield's work became the basis for the first APL [[complex number]] implementation, in [[SHARP APL]].<ref>[[Eugene McDonnell]]. SATN-40: [https://www.jsoftware.com/papers/satn40.htm Complex Numbers]. 1981-06-20.</ref> Conjugate was supported in SHARP and all later APLs to implement complex numbers. | |||
== See also == | |||
* [[Circular]] | |||
* [[Complex (function)|Complex]] | |||
* [[Imaginary]] | |||
== External links == | == External links == | ||
Line 52: | Line 62: | ||
=== Documentation === | === Documentation === | ||
* [ | * [https://help.dyalog.com/latest/index.htm#Language/Primitive%20Functions/Conjugate.htm Dyalog] | ||
* [http://microapl.com/apl_help/ch_020_020_010.htm APLX] | * [http://microapl.com/apl_help/ch_020_020_010.htm APLX] | ||
Line 58: | Line 68: | ||
* [https://www.jsoftware.com/help/dictionary/d100.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/plus J NuVoc] | * [https://www.jsoftware.com/help/dictionary/d100.htm J Dictionary], [https://code.jsoftware.com/wiki/Vocabulary/plus J NuVoc] | ||
* [https://mlochbaum.github.io/BQN/doc/arithmetic.html#basic-arithmetic BQN] | |||
== References == | |||
<references/> | |||
{{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]] | {{APL built-ins}}[[Category:Primitive functions]][[Category:Scalar monadic functions]] |
Latest revision as of 01:19, 18 March 2024
+
|
Conjugate (+
) is a monadic scalar function which negates the imaginary component of a complex argument. Because many APLs do not have a dedicated Identity function, but also do not support complex numbers, Conjugate is often used to return the argument unchanged. This usage is discouraged in modern APLs in favor of the Identity function (usually ⊢
). Conjugate shares the glyph +
with Add.
Examples
Conjugate leaves real numbers unchanged but negates the imaginary part of complex numbers.
+ 0 2 ¯1.1 1E300 ¯200 0 2 ¯1.1 1E300 ¯200 + 2J3 ¯4J¯3 ¯12 1.5J1.5 2J¯3 ¯4J3 ¯12 1.5J¯1.5
As identity function
In early APLs Conjugate was frequently used to return the argument unchanged, for example to display a shy result or break up stranding:
+a←2 3 2 3 *∘2⍣3 +a 256 6561
Sometimes the name "Identity" was even used for +
. Although this usage is becoming rare among new APLers, it may still affect the behavior of Conjugate. For instance, in Dyalog APL, Conjugate will allow a non-numeric argument and return it unchanged even though other monadic scalar functions give a DOMAIN ERROR:
+ ⎕NULL [Null] - ⎕NULL DOMAIN ERROR -⎕NULL ∧
Note that other APLs, e.g. APLX (which does not support complex numbers) and APL2 do not allow applying Conjugate to non-numeric data.
Properties
Like Negate, Conjugate is its own Inverse.
The conjugate of a number is proportional to (that is, a real multiple of) its Reciprocal. Specifically, since for any complex number z
, z×+z
(+z)×z
is a real number (the square of the Magnitude of z
), we have z×((+z)÷z×+z)
1
, so by definition (+z)÷z×+z
is ÷z
. If z
is a unit complex number (for instance the result of Signum), then +z
÷z
.
Hypercomplex numbers
The conjugate of a hypercomplex number (a quaternion or octonion) negates all imaginary components, that is, every component but the real part. Somewhat surprisingly, this maintains the property that z×+z
(+z)×z
is a real number. Therefore the conjugate can be used to define the reciprocal of a complex number using only real division (dividing a hypercomplex number by a real number divides each component by that numer).
Numerical precision
Like Negate, Conjugate almost never suffers issues with numerical precision. This is because negating a component of a complex number is exact in all common number systems.
History
In early APLs, which did not support complex numbers, monadic +
returned its argument unchanged; however, this was not initially considered as a restriction of the complex conjugate to real numbers. In fact, Phil Abrams' report on IVSYS/7090 defined +A
to be 0+A
, implying that the function should extend to the identity on complex numbers as well. The extension to complex conjugate was included in a 1977 proposal by Paul Penfield,[1] who noted that it had already appeared in a 1975 IBM publication documenting APL.[2] Penfield's work became the basis for the first APL complex number implementation, in SHARP APL.[3] Conjugate was supported in SHARP and all later APLs to implement complex numbers.
See also
External links
Mathematics
Documentation
References
- ↑ Paul Penfield. Notation for complex "part" functions. APL Quote Quad Volume 8, Issue 1. 1977-09.
- ↑ IBM. APL Language. GC26-3847-0. 1975-03.
- ↑ Eugene McDonnell. SATN-40: Complex Numbers. 1981-06-20.