Comparison with traditional mathematics: Difference between revisions

Jump to navigation Jump to search
m
Text replacement - "<source" to "<syntaxhighlight"
m (Text replacement - "<source" to "<syntaxhighlight")
Tags: Mobile edit Mobile web edit
Line 5: Line 5:
APL [[Iverson notation|developed from TMN]], and much of APL will be immediately recognised by a mathematician. Interestingly, it seems that the look of the typeface and identifiers (names of variables etc.) used in APL makes a big difference in the reader's perception. A fixed-width typewriter-style font with long identifiers gives the impression of computer source code, while an italic serif typeface and single-letter identifiers gives the impression of scientific formulae. Compare the impression you get when reading the following two expressions which is both valid APL (though it has superfluous parentheses) and traditional mathematics:
APL [[Iverson notation|developed from TMN]], and much of APL will be immediately recognised by a mathematician. Interestingly, it seems that the look of the typeface and identifiers (names of variables etc.) used in APL makes a big difference in the reader's perception. A fixed-width typewriter-style font with long identifiers gives the impression of computer source code, while an italic serif typeface and single-letter identifiers gives the impression of scientific formulae. Compare the impression you get when reading the following two expressions which is both valid APL (though it has superfluous parentheses) and traditional mathematics:
<div style="text-align:center">
<div style="text-align:center">
<source lang=apl inline>((x + y) × (x - y)) = (f ∘ g)(x, y)</source>
<syntaxhighlight lang=apl inline>((x + y) × (x - y)) = (f ∘ g)(x, y)</source>


<math>((x + y) \times (x - y)) = (f \circ g)(x, y)</math>
<math>((x + y) \times (x - y)) = (f \circ g)(x, y)</math>
Line 18: Line 18:
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
|-
|-
| <math>\sim q</math>    || <source lang="apl" inline>~ q</source>  || [[Not]]
| <math>\sim q</math>    || <syntaxhighlight lang="apl" inline>~ q</source>  || [[Not]]
|-
|-
| <math>p \vee q</math> || <source lang="apl" inline>p ∨ q</source> || [[Or]]
| <math>p \vee q</math> || <syntaxhighlight lang="apl" inline>p ∨ q</source> || [[Or]]
|-
|-
| <math>p \wedge q</math>  || <source lang="apl" inline>p ∧ q</source> || [[And]]
| <math>p \wedge q</math>  || <syntaxhighlight lang="apl" inline>p ∧ q</source> || [[And]]
|-
|-
| <math>a \times b</math> || <source lang="apl" inline>a × b</source> || [[Multiply]]
| <math>a \times b</math> || <syntaxhighlight lang="apl" inline>a × b</source> || [[Multiply]]
|-
|-
| <math>a \div b</math>  || <source lang="apl" inline>a ÷ b</source> || [[Divide]]
| <math>a \div b</math>  || <syntaxhighlight lang="apl" inline>a ÷ b</source> || [[Divide]]
|-
|-
| <math>a \in S</math>    || <source lang="apl" inline>a ∊ S</source> || [[Membership]]
| <math>a \in S</math>    || <syntaxhighlight lang="apl" inline>a ∊ S</source> || [[Membership]]
|-
|-
| <math>A \cup B</math>  || <source lang="apl" inline>A ∪ B</source> || [[Union]]
| <math>A \cup B</math>  || <syntaxhighlight lang="apl" inline>A ∪ B</source> || [[Union]]
|-
|-
| <math>A \cap B</math>  || <source lang="apl" inline>A ∩ B</source> || [[Intersection]]
| <math>A \cap B</math>  || <syntaxhighlight lang="apl" inline>A ∩ B</source> || [[Intersection]]
|}
|}


Line 42: Line 42:
! style="width:25%" | Traditional notation !! style="width:25%" | <small>Parenthesised<br></small>APL !! style="width:25%" | <small>Normal<br></small>APL !! Article
! style="width:25%" | Traditional notation !! style="width:25%" | <small>Parenthesised<br></small>APL !! style="width:25%" | <small>Normal<br></small>APL !! Article
|-
|-
| <math>[a \equiv b]</math>  || <source lang="apl" inline>(a ≡ b)</source>    || <source lang="apl" inline>a ≡ b</source>  || [[Match]]
| <math>[a \equiv b]</math>  || <syntaxhighlight lang="apl" inline>(a ≡ b)</source>    || <syntaxhighlight lang="apl" inline>a ≡ b</source>  || [[Match]]
|-
|-
| <math>[a=b]</math>          || <source lang="apl" inline>(a = b)</source>    || <source lang="apl" inline>a = b</source>  || [[Equal]]
| <math>[a=b]</math>          || <syntaxhighlight lang="apl" inline>(a = b)</source>    || <syntaxhighlight lang="apl" inline>a = b</source>  || [[Equal]]
|-
|-
| <math>[a \ne b]</math>      || <source lang="apl" inline>(a ≠ b)</source>    || <source lang="apl" inline>a ≠ b</source>  || [[Not Equal]]
| <math>[a \ne b]</math>      || <syntaxhighlight lang="apl" inline>(a ≠ b)</source>    || <syntaxhighlight lang="apl" inline>a ≠ b</source>  || [[Not Equal]]
|-
|-
| <math>[a \le b]</math>      || <source lang="apl" inline>(a ≤ b)</source>    || <source lang="apl" inline>a ≤ b</source>  || [[Less Than or Equal]]
| <math>[a \le b]</math>      || <syntaxhighlight lang="apl" inline>(a ≤ b)</source>    || <syntaxhighlight lang="apl" inline>a ≤ b</source>  || [[Less Than or Equal]]
|-
|-
| <math>(f \circ g)(x)</math> || <source lang="apl" inline>(f ∘ g)(x)</source> || <source lang="apl" inline>f ∘ g x</source> || [[Bind]]
| <math>(f \circ g)(x)</math> || <syntaxhighlight lang="apl" inline>(f ∘ g)(x)</source> || <syntaxhighlight lang="apl" inline>f ∘ g x</source> || [[Bind]]
|-
|-
| <math>f(g(x))</math>        || <source lang="apl" inline>f(g(x))</source>    || <source lang="apl" inline>f g x</source>  ||
| <math>f(g(x))</math>        || <syntaxhighlight lang="apl" inline>f(g(x))</source>    || <syntaxhighlight lang="apl" inline>f g x</source>  ||
|-
|-
| <math>(f+g)(x)</math>      || <source lang="apl" inline>(f+g)(x)</source>  || <source lang="apl" inline>(f+g) x</source> || [[Train]]s
| <math>(f+g)(x)</math>      || <syntaxhighlight lang="apl" inline>(f+g)(x)</source>  || <syntaxhighlight lang="apl" inline>(f+g) x</source> || [[Train]]s
|}
|}


Line 68: Line 68:
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
|-
|-
| <math>n \pi</math>            || <source lang="apl" inline>○n</source> || [[Pi Times]]
| <math>n \pi</math>            || <syntaxhighlight lang="apl" inline>○n</source> || [[Pi Times]]
|-
|-
| <math>x!</math>                || <source lang="apl" inline>!x</source> || [[Factorial]]
| <math>x!</math>                || <syntaxhighlight lang="apl" inline>!x</source> || [[Factorial]]
|-
|-
| <math>|x|</math>              || <source lang="apl" inline>|x</source> || [[Magnitude]]
| <math>|x|</math>              || <syntaxhighlight lang="apl" inline>|x</source> || [[Magnitude]]
|-
|-
| <math>\lceil x \rceil</math>  || <source lang="apl" inline>⌈x</source> || [[Ceiling]]
| <math>\lceil x \rceil</math>  || <syntaxhighlight lang="apl" inline>⌈x</source> || [[Ceiling]]
|-
|-
| <math>\lfloor x \rfloor</math> || <source lang="apl" inline>⌊x</source> || [[Floor]]
| <math>\lfloor x \rfloor</math> || <syntaxhighlight lang="apl" inline>⌊x</source> || [[Floor]]
|}
|}


Line 85: Line 85:
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
|-
|-
| <math>ab</math>            || <source lang="apl" inline>a×b</source>    || [[Multiply]]
| <math>ab</math>            || <syntaxhighlight lang="apl" inline>a×b</source>    || [[Multiply]]
|-
|-
| <math>e^x</math>          || <source lang="apl" inline> *x</source>    || [[Exponential]]
| <math>e^x</math>          || <syntaxhighlight lang="apl" inline> *x</source>    || [[Exponential]]
|-
|-
| <math>a^b</math>          || <source lang="apl" inline>a*b</source>    || [[Power]]
| <math>a^b</math>          || <syntaxhighlight lang="apl" inline>a*b</source>    || [[Power]]
|-
|-
| <math>\sqrt[a]{b}</math>  || <source lang="apl" inline>a√b</source>    || [[Root]]
| <math>\sqrt[a]{b}</math>  || <syntaxhighlight lang="apl" inline>a√b</source>    || [[Root]]
|-
|-
| <math>\tbinom{n}{k}</math> || <source lang="apl" inline>k!n</source>    || [[Binomial]]
| <math>\tbinom{n}{k}</math> || <syntaxhighlight lang="apl" inline>k!n</source>    || [[Binomial]]
|-
|-
| <math>f^n(x)</math>        || <source lang="apl" inline>(f⍣n) x</source> || [[Power operator]]
| <math>f^n(x)</math>        || <syntaxhighlight lang="apl" inline>(f⍣n) x</source> || [[Power operator]]
|-
|-
| <math>\sin^n(x)</math>    || <source lang="apl" inline>(1○x)*n</source> || [[Circle function]]
| <math>\sin^n(x)</math>    || <syntaxhighlight lang="apl" inline>(1○x)*n</source> || [[Circle function]]
|-
|-
| <math>a\cdot b</math>      || <source lang="apl" inline>a+.×b</source>  || [[Inner product]]
| <math>a\cdot b</math>      || <syntaxhighlight lang="apl" inline>a+.×b</source>  || [[Inner product]]
|}
|}


Line 108: Line 108:
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
|-
|-
| <math>f^n(x)</math>            || <source lang="apl" inline>(f⍣n) x</source>          || [[Power operator]]
| <math>f^n(x)</math>            || <syntaxhighlight lang="apl" inline>(f⍣n) x</source>          || [[Power operator]]
|-
|-
| <math>\sin^n(x)</math>          || <source lang="apl" inline>(1○x)*n</source>          || [[Circle function]]
| <math>\sin^n(x)</math>          || <syntaxhighlight lang="apl" inline>(1○x)*n</source>          || [[Circle function]]
|-
|-
| <math>a\pm b</math>            || <source lang="apl" inline>a(+,-)b</source>          || [[Train]]s
| <math>a\pm b</math>            || <syntaxhighlight lang="apl" inline>a(+,-)b</source>          || [[Train]]s
|-
|-
| <math>a\mp b</math>            || <source lang="apl" inline>a(-,+)b</source>          || [[Train]]s
| <math>a\mp b</math>            || <syntaxhighlight lang="apl" inline>a(-,+)b</source>          || [[Train]]s
|-
|-
| <math>\frac{a}{b}</math>        || <source lang="apl" inline>a÷b</source>              || [[Divide]]
| <math>\frac{a}{b}</math>        || <syntaxhighlight lang="apl" inline>a÷b</source>              || [[Divide]]
|-
|-
| <math>e^x</math>                || <source lang="apl" inline> *x</source>              || [[Exponential]]
| <math>e^x</math>                || <syntaxhighlight lang="apl" inline> *x</source>              || [[Exponential]]
|-
|-
| <math>a^b</math>                || <source lang="apl" inline>a*b</source>              || [[Power function]]
| <math>a^b</math>                || <syntaxhighlight lang="apl" inline>a*b</source>              || [[Power function]]
|-
|-
| <math>\log_a{b}</math>          || <source lang="apl" inline>a⍟b</source>              || [[Logarithm]]
| <math>\log_a{b}</math>          || <syntaxhighlight lang="apl" inline>a⍟b</source>              || [[Logarithm]]
|-
|-
| <math>\sqrt[a]{b}</math>        || <source lang="apl" inline>a√b</source>              || [[Root]]
| <math>\sqrt[a]{b}</math>        || <syntaxhighlight lang="apl" inline>a√b</source>              || [[Root]]
|-
|-
| <math>\tbinom{n}{k}</math>      || <source lang="apl" inline>k!n</source>              || [[Binomial]]
| <math>\tbinom{n}{k}</math>      || <syntaxhighlight lang="apl" inline>k!n</source>              || [[Binomial]]
|-
|-
| <math>\left\{
| <math>\left\{
Line 132: Line 132:
     a, & \text{if } p(x) \\
     a, & \text{if } p(x) \\
     b, & \text{if } q(x)
     b, & \text{if } q(x)
   \end{array}\right.</math>      || <source lang="apl">{p x: a  
   \end{array}\right.</math>      || <syntaxhighlight lang="apl">{p x: a  
  q x: b}</source> || [[dfn]]s
  q x: b}</source> || [[dfn]]s
|-
|-
| <math>\sum_{i=1}^{N} v_i</math> || <source lang="apl" inline>+/v</source>              || [[Reduce]]
| <math>\sum_{i=1}^{N} v_i</math> || <syntaxhighlight lang="apl" inline>+/v</source>              || [[Reduce]]
|-
|-
| <math>\sum_{n=1}^{N} n</math>  || <source lang="apl" inline>+/⍳N</source>              || [[Reduce]], [[Iota]]
| <math>\sum_{n=1}^{N} n</math>  || <syntaxhighlight lang="apl" inline>+/⍳N</source>              || [[Reduce]], [[Iota]]
|-
|-
| <math>\prod_{n=1}^{N} n</math>  || <source lang="apl" inline>×/⍳N</source>              || [[Reduce]], [[Iota]]
| <math>\prod_{n=1}^{N} n</math>  || <syntaxhighlight lang="apl" inline>×/⍳N</source>              || [[Reduce]], [[Iota]]
|}
|}


Line 149: Line 149:
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
! style="width:33%" | Traditional notation !! style="width:33%" | APL !! Article
|-
|-
| <math>e^x</math>                || <source lang="apl" inline> *x</source>              || [[Exponential]]
| <math>e^x</math>                || <syntaxhighlight lang="apl" inline> *x</source>              || [[Exponential]]
|-
|-
| <math>\ln{x}</math>            || <source lang="apl" inline> ⍟b</source>              || [[Natural Logarithm]]
| <math>\ln{x}</math>            || <syntaxhighlight lang="apl" inline> ⍟b</source>              || [[Natural Logarithm]]
|-
|-
| <math>\log_a{b}</math>          || <source lang="apl" inline>a⍟b</source>              || [[Logarithm]]
| <math>\log_a{b}</math>          || <syntaxhighlight lang="apl" inline>a⍟b</source>              || [[Logarithm]]
|-
|-
| <math>a \bmod b</math>          || <source lang="apl" inline>b|a</source>              || [[Modulus]]
| <math>a \bmod b</math>          || <syntaxhighlight lang="apl" inline>b|a</source>              || [[Modulus]]
|-
|-
| <math>\left\{
| <math>\left\{
Line 161: Line 161:
     a, & \text{if } p(x) \\
     a, & \text{if } p(x) \\
     b, & \text{if } q(x)
     b, & \text{if } q(x)
   \end{array}\right.</math>      || <source lang="apl">{p x: a  
   \end{array}\right.</math>      || <syntaxhighlight lang="apl">{p x: a  
  q x: b}</source> || [[dfn]]s
  q x: b}</source> || [[dfn]]s
|-
|-
| <math>\text{let } n=42</math>  || <source lang="apl" inline>n←42</source>              || [[Assignment]]
| <math>\text{let } n=42</math>  || <syntaxhighlight lang="apl" inline>n←42</source>              || [[Assignment]]
|}
|}


Line 174: Line 174:
! style="width:50%" | Traditional notation !! APL
! style="width:50%" | Traditional notation !! APL
|-
|-
| <math>\sum_{i=1}^{N} v_i</math> || <source lang="apl" inline>+/ v  </source>
| <math>\sum_{i=1}^{N} v_i</math> || <syntaxhighlight lang="apl" inline>+/ v  </source>
|-
|-
| <math>\sum_{n=1}^{N} n</math>  || <source lang="apl" inline>+/ ⍳N </source>
| <math>\sum_{n=1}^{N} n</math>  || <syntaxhighlight lang="apl" inline>+/ ⍳N </source>
|-
|-
| <math>\prod_{n=1}^{N} n</math>  || <source lang="apl" inline>×/ ⍳N </source>
| <math>\prod_{n=1}^{N} n</math>  || <syntaxhighlight lang="apl" inline>×/ ⍳N </source>
|-
|-
| <math>\forall x, P(x)</math>    || <source lang="apl" inline>∧/P(x)</source>
| <math>\forall x, P(x)</math>    || <syntaxhighlight lang="apl" inline>∧/P(x)</source>
|-
|-
| <math>\exists x, P(x)</math>    || <source lang="apl" inline>∨/P(x)</source>
| <math>\exists x, P(x)</math>    || <syntaxhighlight lang="apl" inline>∨/P(x)</source>
|}
|}
== Practical example ==
== Practical example ==
Line 190: Line 190:
! style="width:50%" | Traditional notation !! APL  
! style="width:50%" | Traditional notation !! APL  
|-
|-
| <math>|\textbf{b}|=\sqrt[2]{\textbf{b}\cdot\textbf{b}}</math> || <source lang=apl>bNorm ← 2 Root b +.× b</source>
| <math>|\textbf{b}|=\sqrt[2]{\textbf{b}\cdot\textbf{b}}</math> || <syntaxhighlight lang=apl>bNorm ← 2 Root b +.× b</source>
|-
|-
| <math>\hat{\textbf{b}} = \textbf{b}\div|\textbf{b}|</math>  ||  <source lang=apl>bHat ← b ÷ bNorm</source>
| <math>\hat{\textbf{b}} = \textbf{b}\div|\textbf{b}|</math>  ||  <syntaxhighlight lang=apl>bHat ← b ÷ bNorm</source>
|-
|-
| <math>\textbf{a}_\textbf{b}=(\textbf{a}\cdot\hat{\textbf{b}})\hat{\textbf{b}}</math>  ||  <source lang=apl>a_b ← (a +.× bHat) × bHat</source>
| <math>\textbf{a}_\textbf{b}=(\textbf{a}\cdot\hat{\textbf{b}})\hat{\textbf{b}}</math>  ||  <syntaxhighlight lang=apl>a_b ← (a +.× bHat) × bHat</source>
|}
|}
</div>
</div>
{{APL syntax}}[[Category:Essays]]
{{APL syntax}}[[Category:Essays]]

Navigation menu