Complex number: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Text replacement - "</source>" to "</syntaxhighlight>") |
||
Line 1: | Line 1: | ||
A '''complex number''' type is a [[number|numeric type]] which represents, usually with some limited precision, the [[wikipedia:Complex number|complex numbers]]. Complex number support is defined as an optional facility in the XAPL standard ([[ISO/IEC 13751:2001]]), and complex numbers are available in many APLs. Usually these numbers are written with a syntax such as <source lang=apl inline>5j2</ | A '''complex number''' type is a [[number|numeric type]] which represents, usually with some limited precision, the [[wikipedia:Complex number|complex numbers]]. Complex number support is defined as an optional facility in the XAPL standard ([[ISO/IEC 13751:2001]]), and complex numbers are available in many APLs. Usually these numbers are written with a syntax such as <source lang=apl inline>5j2</syntaxhighlight> or <source lang=apl inline>5J2</syntaxhighlight> for the complex number with real part 5 and imaginary part 2. | ||
== Examples == | == Examples == | ||
Line 7: | Line 7: | ||
1J¯2 + 3J4 | 1J¯2 + 3J4 | ||
4J2 | 4J2 | ||
</ | </syntaxhighlight> | ||
The [[Circle function]] can be used to split a complex number into its components: a left argument of 9 gets the real part and a left argument of 11 gets the imaginary part. With the [[Rank operator]], Circle can be used to convert a [[shape]] <source lang=apl inline>s</ | The [[Circle function]] can be used to split a complex number into its components: a left argument of 9 gets the real part and a left argument of 11 gets the imaginary part. With the [[Rank operator]], Circle can be used to convert a [[shape]] <source lang=apl inline>s</syntaxhighlight> complex array to a shape <source lang=apl inline>s,2</syntaxhighlight> real array where each row contains the components of one complex number. | ||
<source lang=apl> | <source lang=apl> | ||
9 11 ○ 12J3 | 9 11 ○ 12J3 | ||
Line 16: | Line 16: | ||
4 3 | 4 3 | ||
2 1 | 2 1 | ||
</ | </syntaxhighlight> | ||
Operations on real numbers can sometimes yield complex numbers. Famously, the square root of minus one is the imaginary unit: | Operations on real numbers can sometimes yield complex numbers. Famously, the square root of minus one is the imaginary unit: | ||
<source lang=apl> | <source lang=apl> | ||
¯1*÷2 | ¯1*÷2 | ||
0J1 | 0J1 | ||
</ | </syntaxhighlight> | ||
== Implementation == | == Implementation == |