Monday, January 16, 2017

Funky Fibs

Given an integer n, what is the nth (nega)Fibonacci number?

nth Fib Amnesic Eidetic Grinder Unitary Lacunar
Fib()
add.count
time (ms)

n:


. . . , 34, -21, 13, -8, 5, -3, 2, -1, 1, 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . .


Some sequences of numbers arise so often in mathematics that we recognize them instantly and give them special names. For example, everybody who learns arithmetic knows the sequence of square numbers. . . . In Chapter 1 we encountered the triangular numbers . . . in Chapter 4 we studied prime numbers . . . in Chapter 5 we looked briefly at the Catalan numbers . . .

In the present chapter we'll get to know a few other important sequences. First on our agenda will be the Stirling numbers . . . and the Eulerian numbers . . . Then we'll take a good look at the harmonic numbers . . . and the Bernoulli numbers . . . Finally, we'll examine the facinating Fibonacci numbers Fn and some of their important generalizations.

Ronald L. Graham, Donald E. Knuth, and Oren Patashnik
Concrete Mathematics: A Foundation for Computer Science (1994)
Chapter 6, p. 243

The sequence

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, . . . ,

in which each number is the sum of the preceding two, plays an important role in at least a dozen seemingly unrelated algorithms which we will study later.
Donald E. Knuth
The Art of Computer Programming, Second Edition (1973)
Volumne 1, Chapter 1, p. 78

The point of view I have adopted while writing these twelve chapters differs from that taken in many contemporary books about computer programming in that I am not trying to teach the reader how to use somebody else's subroutines; I am concerned with teaching the reader how to write better subroutines himself!
ibid.
Preface, p. viii

Masculine pronouns in this book are usually not intended to connote gender. Occasional chauvinistic comments are not to be taken seriously.
ibid.
p. v



Amnesic Fib

You may forget more than most people know after reading Wikipedia. For example, according to an article about amnesia on Wikipedia:

Patients with amnesia can learn new information, particularly non-declarative knowledge. However, some patients with dense anterograde amnesia do not remember the episodes during which they learned or observed the information previously.
Did I mention Wikipedia?



Eidetic Fib

For as long as it exists, brief as that period may be, an instance of EideticFib observes and is able to recall, within limits, many things pertinent to future questions.

Eidetic memory (/ˈdɛtɪk/; sometimes called photographic memory[1]) is an ability to vividly recall images from memory after only a few instances of exposure, with high precision for a brief time after exposure,[2] without using a mnemonic device.[3] Although the terms eidetic memory and photographic memory may be used interchangeably,[2] they are also distinguished, with eidetic memory referring to the ability to view memories like photographs for a few minutes,[4] and photographic memory referring to the ability to recall page or text numbers, or similar, in great detail.[5][6] In the case of distinguishing the concepts, eidetic memory has been documented while photographic memory is a popular culture myth that has never been demonstrated to exist.[6][7]
Wikipedia: Eidetic memory



Grinder Fib

According to yet another Wikipedia article: “Grinding is a term used in video gaming to describe the process of engaging in repetitive tasks.”



Unitary Fib

If you have faith in the article about Unitarianism on Wikipedia, then you may know that:

Unitarianism is historically a Christian theological movement named for its belief that God is one entity, as opposed to the Trinity, which defines God as three persons in one being — the Father, Son, and Holy Spirit. Unitarians believe that Jesus was inspired by God in his moral teachings and is a Savior, but he is perceived as a human rather than a deity.
In a sense (granted, one might say it's a stretch), GrinderFib treats the nth Fibonacci number as one entity, as opposed to, say, AmnesiceFib, which views (but unfortunately doesn't remember) the same value as a trinity—the two in one: F(n) = F(n-1) + F(n-2). This makes remembering a little simpler and probably a lot less profitable.



Lacunar Fib

Last but not leased:

"Lacuna matata" is a Svahili phrase; roughly translated, it means "no worries". It is formed by the words lacuna (there is not here) and matata (plural form of problem).



It's 3 AM. Do you know where your POTUS is?


*    *    *

Supporting Characters

A supporting character is a character in a narrative that is not focused on by the primary storyline, but appears or is mentioned in the story enough to be more than just a minor character or a cameo appearance. Sometimes, supporting characters may develop a complex back-story of their own, but this is usually in relation to the main character, rather than entirely independently.

Keep count...

Wikipedia tells us that “[b]esides counting fruits, addition can also represent combining other physical objects.” In fact, using addition we can count the number of times we've performed addition! And this might aid in the analysis of algorithms used to implement functions that yield Fibonacci numbers—elements of the sequence that, according to the authors of Concrete Mathematics: A Foundation for Computer Science, “is perhaps the most pleasant of all” (370).



Be wary!

Be wary of arguments passed to functions in weakly typed languages!

In computer programming, programming languages are often colloquially classified as strongly typed or weakly typed (loosely typed). These terms do not have a precise definition, but in general, a strongly typed language is more likely to generate an error or refuse to compile if the argument passed to a function does not closely match the expected type. On the other hand, a very weakly typed language may produce unpredictable results or may perform implicit type conversion.



And to remember, use a dictionary.

Also according to Wikipedia:

The term "memoization" was coined by Donald Michie in 1968 and is derived from the Latin word "memorandum" ("to be remembered"), usually truncated as "memo" in the English language, and thus carries the meaning of "turning [the results of] a function into something to be remembered."

In computer science, an associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears at most once in the collection. . . . Many programming languages include associative arrays as primitive data types . . . Associative arrays have many applications including such fundamental programming patterns as memoization and the decorator pattern.

In computing, a cache is a hardware or software component that stores data so future requests for that data can be served faster; the data stored in a cache might be the result of an earlier computation, or the duplicate of data stored elsewhere.