diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-12-03 22:06:33 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-12-03 22:06:33 -0500 |
| commit | 130302ec19f786a842786961848f327e3cd8618c (patch) | |
| tree | 3f52d006ba7110f707f779697f56ac10436552cc /docs/spec/complex.html | |
| parent | 8038e6f0fd5d8f0b4f2eb6d685eb42b8f14c6cd9 (diff) | |
Add missed complex extension page
Diffstat (limited to 'docs/spec/complex.html')
| -rw-r--r-- | docs/spec/complex.html | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/spec/complex.html b/docs/spec/complex.html new file mode 100644 index 00000000..a5d4826e --- /dev/null +++ b/docs/spec/complex.html @@ -0,0 +1,14 @@ +<head> + <link href="../favicon.ico" rel="shortcut icon" type="image/x-icon"/> + <link href="../style.css" rel="stylesheet"/> + <title>BQN Specification: Complex numbers</title> +</head> +<div class="nav">(<a href="https://github.com/mlochbaum/BQN">github</a>) / <a href="../index.html">BQN</a> / <a href="index.html">spec</a></div> +<h1 id="specification-complex-numbers"><a class="header" href="#specification-complex-numbers">Specification: Complex numbers</a></h1> +<p>Complex numbers are an optional extension to BQN's numeric system. If they are supported, the following functionality must also be supported. This extension is a draft and is versioned separately from the rest of the BQN specification.</p> +<p>A <em>complex number</em> is a value with two <em>components</em>, a <em>real part</em> and an <em>imaginary part</em>. The type of each component is a real number, as described in the <a href="types.html">type</a> specification. However, this type replaces the number type given there.</p> +<p>The <a href="literal.html">numeric literal</a> notation is extended with the character <code><span class='Value'>i</span></code>, which separates two real-valued components (in effect, it has lower "precedence" than other characters like <code><span class='Value'>e</span></code> and <code><span class='Number'>¯</span></code>). If a second component is present (using <code><span class='Value'>i</span></code> or <code><span class='Function'>I</span></code>), that component's value is multiplied by the <a href="https://en.wikipedia.org/wiki/Imaginary_unit">imaginary unit</a> <em>i</em> and added to the first component; otherwise the value is the first component's value without modification. As with real numbers, the exact complex number given is rounded to fit the number system in use.</p> +<pre><span class='Value'>complexnumber</span> <span class='Function'>=</span> <span class='Value'>number</span> <span class='Paren'>(</span> <span class='Paren'>(</span> <span class='String'>"i"</span> <span class='Function'>|</span> <span class='String'>"I"</span> <span class='Paren'>)</span> <span class='Value'>number</span> <span class='Paren'>)</span><span class='Value'>?</span> +</pre> +<p>Basic arithmetic functions <code><span class='Function'>+-×÷</span></code> are extended to complex numbers. A monadic case for the function <code><span class='Function'>+</span></code> is added, which returns the conjugate argument: a number with real part equal to the real part of <code><span class='Value'>𝕩</span></code> and imaginary part negated relative to <code><span class='Value'>𝕩</span></code>.</p> +<p>The primitive function <code><span class='Value'>⍳</span></code> is added: the character <code><span class='Value'>⍳</span></code> forms a primitive function <a href="token.html">token</a>, and its value is the function <code><span class='Brace'>{</span><span class='Value'>𝕨</span><span class='Function'>⊢</span><span class='Modifier2'>⊘</span><span class='Function'>+</span><span class='Number'>0j1</span><span class='Function'>×</span><span class='Value'>𝕩</span><span class='Brace'>}</span></code>. This function multiplies <code><span class='Value'>𝕩</span></code> by <em>i</em>, then adds <code><span class='Value'>𝕨</span></code> if given.</p> |
