Complex floor: Difference between revisions

Jump to navigation Jump to search
243 bytes added ,  21:50, 10 September 2022
m
Text replacement - "<source" to "<syntaxhighlight"
mNo edit summary
m (Text replacement - "<source" to "<syntaxhighlight")
Tags: Mobile edit Mobile web edit
Line 5: Line 5:
In this article, an ''integer'' refers to a [[wikipedia:Gaussian integer|Gaussian integer]], a complex number whose real and imaginary parts are integers.
In this article, an ''integer'' refers to a [[wikipedia:Gaussian integer|Gaussian integer]], a complex number whose real and imaginary parts are integers.


In code fragments, <source lang=apl inline>re</source> and <source lang=apl inline>im</source> refer to functions that return the real and imaginary part of the given complex number respectively. They are available as a part of [[Circular]], namely <source lang=apl inline>9○</source> and <source lang=apl inline>11○</source>.
In code fragments, <syntaxhighlight lang=apl inline>re</source> and <syntaxhighlight lang=apl inline>im</source> refer to functions that return the real and imaginary part of the given complex number respectively. They are available as a part of [[Circular]], namely <syntaxhighlight lang=apl inline>9○</source> and <syntaxhighlight lang=apl inline>11○</source>.


== Concept ==
== Concept ==
Line 15: Line 15:
:# ''Fractionality''. The magnitude of the difference of a number and its floor shall be less than one. This property must be satisfied to guarantee that remainders are less in magnitude than divisors. It may be called the fundamental property of the floor function.
:# ''Fractionality''. The magnitude of the difference of a number and its floor shall be less than one. This property must be satisfied to guarantee that remainders are less in magnitude than divisors. It may be called the fundamental property of the floor function.
:# ''Integrity''. The floor of a number is an integer.
:# ''Integrity''. The floor of a number is an integer.
:# ''Convexity''. If <source lang=apl inline>g</source> is the floor of the numbers <source lang=apl inline>z</source> and <source lang=apl inline>w</source>, then it is also the floor of all numbers on the line segment between <source lang=apl inline>z</source> and <source lang=apl inline>w</source>.
:# ''Convexity''. If <syntaxhighlight lang=apl inline>g</source> is the floor of the numbers <syntaxhighlight lang=apl inline>z</source> and <syntaxhighlight lang=apl inline>w</source>, then it is also the floor of all numbers on the line segment between <syntaxhighlight lang=apl inline>z</source> and <syntaxhighlight lang=apl inline>w</source>.
:# ''Integer Translation''. For <source lang=apl inline>c</source> a complex integer, <source lang=apl inline>(c+⌊z) = ⌊(c+z)</source>.
:# ''Integer Translation''. For <syntaxhighlight lang=apl inline>c</source> a complex integer, <syntaxhighlight lang=apl inline>(c+⌊z) = ⌊(c+z)</source>.
:# ''Compatability''. The complex floor function is compatible with the real floor function. Furthermore, its action on purely imaginary numbers is similar to the action of the real floor function on real numbers. In particular, <source lang=apl inline>(re⌊z)≤re⌈z</source> and <source lang=apl inline>(im⌊z)≤im⌈z</source>.
:# ''Compatability''. The complex floor function is compatible with the real floor function. Furthermore, its action on purely imaginary numbers is similar to the action of the real floor function on real numbers. In particular, <syntaxhighlight lang=apl inline>(re⌊z)≤re⌈z</source> and <syntaxhighlight lang=apl inline>(im⌊z)≤im⌈z</source>.


Then he proposed a shape on the complex plane that satisfies all seven requirements: a rectangle of width <source lang=apl inline>√2</source> and height <source lang=apl inline>√÷2</source>, rotated 45 degrees clockwise so that the midpoint of the bottom side is placed on an integer <source lang=apl inline>b</source>, and the top two corners are placed on <source lang=apl inline>b+0j1</source> and <source lang=apl inline>b+1</source> respectively. The following is the APL model by McDonnell, rewritten using [[dfn]]s:
Then he proposed a shape on the complex plane that satisfies all seven requirements: a rectangle of width <syntaxhighlight lang=apl inline>√2</source> and height <syntaxhighlight lang=apl inline>√÷2</source>, rotated 45 degrees clockwise so that the midpoint of the bottom side is placed on an integer <syntaxhighlight lang=apl inline>b</source>, and the top two corners are placed on <syntaxhighlight lang=apl inline>b+0j1</source> and <syntaxhighlight lang=apl inline>b+1</source> respectively. The following is the APL model by McDonnell, rewritten using [[dfn]]s:


<source lang=apl>
<syntaxhighlight lang=apl>
Floor←{
Floor←{
   r←re ⍵
   r←re ⍵
Line 36: Line 36:
== Application to other primitives ==
== Application to other primitives ==


[[Ceiling]] <source lang=apl inline>⌈x</source> was extended via the property <source lang=apl inline>(⌈x) = -⌊-x</source>.
[[Ceiling]] <syntaxhighlight lang=apl inline>⌈x</source> was extended via the property <syntaxhighlight lang=apl inline>(⌈x) = -⌊-x</source>.


[[Residue]] <source lang=apl inline>x|y</source> was extended by the definition <source lang=apl inline>(w|z) = z-w×⌊z÷w+w=0</source>. The property of Fractionality ensures that the residue is always smaller in [[magnitude]] than the divisor.
[[Residue]] <syntaxhighlight lang=apl inline>x|y</source> was extended by the definition <syntaxhighlight lang=apl inline>(w|z) = z-w×⌊z÷w+w=0</source>. The property of Fractionality ensures that the residue is always smaller in [[magnitude]] than the divisor.


[[GCD]] <source lang=apl inline>x∨y</source> was extended by using the Euclidean algorithm, which is guaranteed to terminate for any pair of complex numbers, again due to Fractionality. The following is the APL model for complex GCD, again using dfns:
[[GCD]] <syntaxhighlight lang=apl inline>x∨y</source> was extended by using the Euclidean algorithm, which is guaranteed to terminate for any pair of complex numbers, again due to Fractionality. The following is the APL model for complex GCD, again using dfns:


<source lang=apl>
<syntaxhighlight lang=apl>
GCD←{
GCD←{
   0=⍺|⍵:⍺
   0=⍺|⍵:⍺
Line 49: Line 49:
</source>
</source>


[[LCM]] <source lang=apl inline>x∧y</source> was extended by using the property <source lang=apl inline>(x∧y) = x×y÷x∨y</source>.
[[LCM]] <syntaxhighlight lang=apl inline>x∧y</source> was extended by using the property <syntaxhighlight lang=apl inline>(x∧y) = x×y÷x∨y</source>.


== References ==
== References ==

Navigation menu