Dijkstra's specification for a million dollar computer in 1965 [pdf]
cs.utexas.edu2 pointsby crntaylor0 comments
We only had 23 years of Python interpreter development,
how would things look like when Python is 42, like C?
C, which I always think of as an ancient venerable systems language, is less than twice as old as Python, which I think of as a hot new kid on the block. 1 / (10^n - 2) = 1/10^n * 1/(1 - 2/10^n)
= 1/10^n * (1 + 2/10^n + 2^2 /10^2n + 2^3 /10^3n + ...)
which gives the observed pattern. It breaks down when 2^k has more than n digits, which happens approximately when 2^k > 10^n => k > n log(10) / log(2)
which comes out to 4 * log(10)/log(2) = 13.28 when n = 4. x / (1 - x)^2 = x + 2x^2 + 3x^3 + 4x^4 + ...
setting x = 1/10^n gives the infinite series 1/10^n + 2/10^2n + 3/10^3n + ...
which leads to the neat fact that 1 / 998001 = 0.000 001 002 003 004 005 006 007...
--- 1000 / 997002999 = 0.000 001 003 006 010 015 021 ...
which goes through the triangle numbers[0] in its expansion, or 1 / 998999 = 0.000 001 001 002 003 005 008 013 021 ...
which goes through the Fibonacci numbers[1]. 1001000 / 997002999 = 0.001 004 009 016 025 036 049 ...
[0] http://en.wikipedia.org/wiki/Triangle_number more (portable and secure)
rather than (more portable) and secure sqrt n = loop x0 x1
where
loop x y = if converged x y
then y
else loop y (0.5 * (y + n/y))
converged x y = abs (x/y - 1) < 1e-10
x0 = 1.0;
x1 = 0.5 * (1.0 + 1.0/n)
That's good, but it has the test for convergence all mixed up with the logic for generating the guesses. What if we could factor out the code that generates an infinite sequence of guesses? sqrtGuesses n = go 1.0
where
go x = x : go (0.5 * (x + n/x))
Note that this works in Haskell because of laziness, but it's simple in any language that has a mechanism for delaying computations. Now we've decoupled the method for generating a sequence of guesses, we can write a function that checks for relative convergence converge (x:y:rest) = if abs (x/y - 1) < 1e-10
then y
else converge (y:rest)
and define the square root function in terms of these sqrt n = converge (sqrtGuesses n)
The logic of the program is now much cleaner, and we've got a useful function 'converge' which can be re-used in other parts of the program. Actor–network theory is an approach to social theory and
research, originating in the field of science studies, which treats
objects as part of social networks. It can technically be described
as a "material-semiotic" method. This means that it maps relations
that are simultaneously material (between things) and semiotic
(between concepts). It assumes that many relations are both
material and semiotic.
Broadly speaking, ANT is a constructivist approach in that it
avoids essentialist explanations of events or innovations (e.g.
explaining a successful theory by understanding the combinations
and interactions of elements that make it successful, rather than
saying it is “true” and the others are “false”). However, it is
distinguished from many other STS and sociological network theories
for its distinct material-semiotic approach. solve = do
coin <- choose (999/1000) fair biased
tosses <- replicateM 10 coin
condition (tosses == replicate 10 Head)
nextToss <- coin
return nextToss
where
fair = choose (1/2) Head Tail
biased = certainly Head
http://www.meetup.com/London-Haskell/