Question

I'm doing a task in a subject were fib(0) is defined to = 1. But that can't be right? fib(0) is 0?

Program with fib(0) = 1; spits out fib(4) = 5
Program with fib(0) = 0; spits out fib(3) = 3

What is the correct definition?

Was it helpful?

Solution

You're correct. The Fibonacci sequence is defined with seed values fib(0) = 0 and fib(1) = 1. This is a requirement for the rest of the sequence to be correct.

The only condition under which fib(0) = 1 could work is if you defined a "-1 based counting system" (as opposed to the usual conventions of 0-based and 1-based). This would be pretty wacky however, I'm sure you agree.

OTHER TIPS

The definition with Fib(0) = 1 is known as the combinatorial definition, and Fib(0) = 0 is the classical definition. Both are used in the Fibonacci Quarterly, though authors that use the combinatorial definition need to add a sentence of explanation. Benjamin and Quinn in Proofs that Really Count use f_n for the nth combinatorial Fibonacci number and F_n for the nth classical Fibonacci number. The combinatorial definition is good, not surprisingly for counting questions like "How many ways are there to walk up a flight of n steps, taking either one or two steps at a time?" When n is 0, there's one way to do it, not zero ways.

From the Fibonacci number entry on Wikipedia:

In mathematics, the Fibonacci numbers are the following sequence of numbers:

alt text

By definition, the first two Fibonacci numbers are 0 and 1, and each remaining number is the sum of the previous two. Some sources omit the initial 0, instead beginning the sequence with two 1s.

In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation

alt text

with seed values

alt text

Based on the definition of the Fibonacci sequence, you can generate a closed form for defining the nth element:

F(n) = ( f^n - (1-f)^n ) / sqrt(5),
where f = (1 + sqrt(5)) / 2 [the golden ratio]

For n = 0 it is clearly 0:

F(0) = (1 - 1) / sqrt(5) = 0.

http://en.wikipedia.org/wiki/Fibonacci_number

Fibonacci himself started the sequence with 1 and not 0. It's important to recognize that one's opinion is not unalterable fact, and it may be worthwhile to consider that you don't necessarily know better than the guy who created the sequence. I think it's fine to start the sequence with 0 just as long as you don't act like that is the one and only absolutely correct way of doing things, as the number at "index 0" is fundamentally ambiguous and should always be communicated explicitly.

The question of "index" only applies to us and not Fibonacci. So if we want to go with his starting number and we're using 0-based indexes we'd put his starting number at index 0, or if we're using 1-based indexes we'd put his starting number at index 1.

And since it is indeed possible to continue the sequence to the left, that also makes starting with 0 totally arbitrary. Why not start with -1 and go -1, 1, 0, 1, 1, 2...?

They are both correct. If you specify a sequence G{n} by the recursion G{1} = 3, G{2} = 5, G{n} = G{ n - 1} + G{ n - 2} then most people would agree that is "a Fibonacci sequence". The only difference being a few terms at the front, but the leading terms are mostly irrelevant for any interesting questions about the sequence. The heart of a Fibonacci sequence is the addition rule, and any sequence that uses that rule is a Fibonacci sequence. It is only necessary to specify whether 0 is in the sequence if you want to ask specific questions about a particular index... every thing else is just a translation on the index and is pretty much irrelevant. That is, if the problem is 'find a closed form solution for the Nth value in the sequence', then solving it for G will solve the problem for F with just a trivial shift of the solution. The hard part of the problem is the same for both sequences.

You cannot have zero rabbits and thus produce a pair, and "how many pairs of rabbits can be produced in a year starting with one pair and reproducing monthly starting with the second month" was the original question to Fibonacci.

fib 0 = 0
fib 1 = 1

That is the seed value definition.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top