Conjugate: Difference between revisions

Jump to navigation Jump to search
171 bytes added ,  22:23, 10 September 2022
m
Text replacement - "</source>" to "</syntaxhighlight>"
m (Text replacement - "<source" to "<syntaxhighlight")
m (Text replacement - "</source>" to "</syntaxhighlight>")
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 <syntaxhighlight lang=apl inline>⊢</source>). Conjugate shares the glyph <syntaxhighlight lang=apl inline>+</source> with [[Add]].
{{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 ==
Line 9: Line 9:
       + 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
</source>
</syntaxhighlight>


== As identity function ==
== As identity function ==
Line 19: Line 19:
       *∘2⍣3 +a
       *∘2⍣3 +a
256 6561
256 6561
</source>
</syntaxhighlight>
Sometimes the name "Identity" was even used for <syntaxhighlight lang=apl inline>+</source>. 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]]:
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>
<syntaxhighlight lang=apl>
       + ⎕NULL
       + ⎕NULL
Line 28: Line 28:
       -⎕NULL
       -⎕NULL
       ∧
       ∧
</source>
</syntaxhighlight>


== Properties ==
== Properties ==
Line 34: Line 34:
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 <syntaxhighlight lang=apl inline>z</source>, <syntaxhighlight lang=apl inline>z×+z</source> {{←→}} <syntaxhighlight lang=apl inline>(+z)×z</source> is a real number (the square of the [[Magnitude]] of <syntaxhighlight lang=apl inline>z</source>), we have <syntaxhighlight lang=apl inline>z×((+z)÷z×+z)</source> {{←→}} <syntaxhighlight lang=apl inline>1</source>, so by definition <syntaxhighlight lang=apl inline>(+z)÷z×+z</source> is <syntaxhighlight lang=apl inline>÷z</source>. If <syntaxhighlight lang=apl inline>z</source> is a unit complex number (for instance the result of [[Signum]]), then <syntaxhighlight lang=apl inline>+z</source> {{←→}} <syntaxhighlight lang=apl inline>÷z</source>.
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 <syntaxhighlight lang=apl inline>z×+z</source> {{←→}} <syntaxhighlight lang=apl inline>(+z)×z</source> 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).
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 ==

Navigation menu