Difference between revisions of "Comparison with traditional mathematics"
Miraheze>Adám Brudzewsky 
m (1 revision imported) 
(No difference)

Revision as of 09:39, 21 November 2019
APL unifies certain notation for some mathematical constructs, and has a more consistent syntax. Below are some examples comparing traditional mathematical notation (denoted TMN in this article) with equivalent APL. Note that some of these examples only work in certain APL dialects.
Contents
Similarities
APL developed from TMN, and much of APL will be immediately recognised by a mathematician. Interestingly, it seems that look of the typeface and identifiers (names of variables etc.) used in APL makes a big difference in the perception of the reader. A fixedwidth typewriterstyle font with long identifiers gives the impression of computer source code, while an italic serif typeface and singleletter 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:
((x + y) × (x  y)) = (f ∘ g)(x, y)
Failed to parse (syntax error): {\displaystyle ((x + y) × (x  y)) = (f ∘ g)(x, y)}
Now note that they are identical, letter for letter. In fact, even the MediaWiki markup code (the language used to define APL Wiki pages) is identical for the two lines identical, except one is tagged as "source" while the other is tagged as "math". Computer Scientists tend to have great difficulty in approaching APL until they let go of the notion that APL is just another programming language (despite its name!) and instead look at it as an executable mathematical notation.
It is notable that APL traditionally was written with a font wherein letters were always italicised, while everything else wasn't. Here is how it looks in the default font for SAX:
Identical
For many basic operations, APL is identical to TMN:
Traditional notation  APL  Article 

~ q 
Not  
Failed to parse (syntax error): {\displaystyle p∨q}  p ∨ q 
Or 
Failed to parse (syntax error): {\displaystyle p∧q}  p ∧ q 
And 
Failed to parse (syntax error): {\displaystyle a×b}  a × b 
Multiply 
Failed to parse (syntax error): {\displaystyle a÷b}  a ÷ b 
Divide 
a ∊ S 
Membership  
Failed to parse (syntax error): {\displaystyle A ∪ B}  A ∪ B 
Union 
Failed to parse (syntax error): {\displaystyle A ∩ B}  A ∩ B 
Intersection 
Redundant brackets and parentheses
Often, the only difference is that APL allows omitting brackets or parenthesis. This is because the Iverson bracket is implied and functions have long right scope.
Traditional notation  Parenthesised APL 
Normal APL 
Article 

Failed to parse (syntax error): {\displaystyle [a≡b]}  (a ≡ b) 
a ≡ b 
Match 
(a = b) 
a = b 
Equal  
Failed to parse (syntax error): {\displaystyle [a≠b]}  (a ≠ b) 
a ≠ b 
Not Equal 
Failed to parse (syntax error): {\displaystyle [a≤b]}  (a ≤ b) 
a ≤ b 
Less Than or Equal 
Failed to parse (syntax error): {\displaystyle (f∘g)(x)}  (f ∘ g)(x) 
f ∘ g x 
Bind 
f(g(x)) 
f g x 

(f+g)(x) 
(f+g) x 
Trains 
Differences
While based on TMN, APL goes a long way to harmonise and generalise its notation.
Prefix
In APL, all functions that only take a single argument are placed to the immediate left of their argument. TMN uses prefix, omnifix, and suffix notations.
Traditional notation  APL  Article 

○n 
Pi Times  
!x 
Factorial  
x 
Magnitude  
Failed to parse (syntax error): {\displaystyle ⌈x⌉}  ⌈x 
Ceiling 
Failed to parse (syntax error): {\displaystyle ⌊x⌋}  ⌊x 
Floor 
Explicitness
APL writes out all functions explicitly while TMN often implies functions by argument positioning without giving the function an explicit symbol.
Traditional notation  APL  Article 

a×b 
Multiply  
*x 
Exponential  
a*b 
Power  
a√b 
Root  
k!n 
Binomial  
(f⍣a) x 
Power operator  
(1○x)*n 
Circle function 
Linearity
APL is strictly linear in the sense that it is written as single lines of uniformly sized and positioned characters, as opposed to TMN which often uses font size and/or position to give meaning.
Traditional notation  APL  Article 

(f⍣a) x 
Power operator  
(1○x)*n 
Circle function  
a(+,)b 
Trains  
a(,+)b 
Trains  
a÷b 
Divide  
*x 
Exponential  
a*b 
Power function  
a⍟b 
Logarithm  
a√b 
Root  
k!n 
Binomial  
{p x: a
q x: b}

dfns  
+/v 
Reduce  
+/⍳N 
Reduce, Iota  
×/⍳N 
Reduce, Iota 
Named functions
APL has no reserved words, and user defined names can have multiple characters. TMN uses multicharacter names for many functions and uses many adhoc control words.
Traditional notation  APL  Article 

*x 
Exponential  
⍟b 
Natural Logarithm  
a⍟b 
Logarithm  
ba 
Modulus  
{p x: a
q x: b}

dfns  
n←42 
Assignment 
Other differences
APL harmonises and generalises all folding and dispenses with TMN's counting variables. Every one of the following calculations is a reduction.
Traditional notation  APL 

+/ v
 
+/ ⍳N
 
×/ ⍳N
 
Failed to parse (syntax error): {\displaystyle ∀ x, P(x)}  ∧/P(x)

Failed to parse (syntax error): {\displaystyle ∃ x, P(x)}  ∨/P(x)
