Why associative operations?
post by Sunny from QAD (Evan Rysdam) · 2020-07-16T12:36:47.802Z · LW · GW · 7 commentsThis is a link post for http://questionsanddaylight.com/?p=88
Contents
7 comments
7 comments
Comments sorted by top scores.
comment by Gurkenglas · 2020-07-16T19:13:37.086Z · LW(p) · GW(p)
In the same vein:
- Commutativity is good in addition to associativity because then you can use Σ
- Structure preservation in a morphism φ (aka φ(xy)=φ(x)φ(y)) is good because then if φ follows from the context, you can replace all of "φ(xyz)" and "φ(xy)φ(z)" and "φ(x)φ(yz)" with "xyz"
- Bijectivity in a function f is good because then for any equation it is an equivalent transformation to apply f to both sides
- Monotonicity in a function f is good because then you can apply it to both sides of an inequality
↑ comment by Pongo · 2020-07-16T22:31:47.193Z · LW(p) · GW(p)
Bijectivity in a function f is good because then for any equation it is an equivalent transformation to apply f to both sides
Don't you just need injectivity here?
Replies from: Gurkenglas↑ comment by Gurkenglas · 2020-07-17T10:28:36.722Z · LW(p) · GW(p)
Huh, you're right. That's too bad, "well-definedness & injectivity" doesn't flow so well, and I don't see what comparable property surjectivity is good for.
↑ comment by Sunny from QAD (Evan Rysdam) · 2020-07-16T19:50:48.924Z · LW(p) · GW(p)
Good stuff, thanks for your comment!
comment by aweinstock · 2020-07-17T19:25:23.311Z · LW(p) · GW(p)
Another thing that you can do when folding associative operations over a sequence is re-parenthesize them in a way that makes them more efficient to compute.
For example, if A is a 1x1000 vector, B is a 1000x1000 square matrix, and C is a 1000x1 vector, (AB)(BC) takes less time and space to compute than A(BB)C since the intermediate 1000x1000 BB needs to be stored explicitly in the latter.
In the following python snippet, the computation of A(BB)C takes around 3/4ths of a second, while (AB)(BC) takes a handful of milliseconds.
from time import time
from numpy.random import random
A = random((1, 1000))
B = random((1000, 1000))
C = random((1000, 1))
a0 = time(); print(A.dot(B.dot(B)).dot(C)); a1 = time(); print(a1 - a0)
b0 = time(); print(A.dot(B).dot(B.dot(C))); b1 = time(); print(b1 - b0)
(Ironically, the values can be slightly different since floating point multiplication and addition aren't associative, unlike the corresponding operations over reals.)
Along the same lines, folds of associative operations over a sequence can be parallelized by parenthesizing the sequence as a balanced binary tree and evaluating the instances of the operation on separate nodes.
comment by Pattern · 2020-07-16T20:08:05.031Z · LW(p) · GW(p)
The website has internal links prefixed with https but the site doesn't work with https.
Replies from: Evan Rysdam↑ comment by Sunny from QAD (Evan Rysdam) · 2020-07-16T20:29:59.259Z · LW(p) · GW(p)
It works, but it's self-certified, so your browser is probably blocking it. You can add an exception if you'd like, but I should have it fixed "soon" (3rd party certification can be gotten for free, I just need to get around to it).
Edit: I have done this now.