In Sequences Part I, we talked about what a sequence is, and then we talked about straight up sequences. If you need a refresher, just visit the post by clicking here.
Today, we’re going to talk about recursive functions for sequences. That is, ones that look like this:
This is a recursive sequence – or one that uses previous terms to define the next term. This particular sequences is called the Fibonacci Sequence. Mostly it’s just a regular sequence that gets a special name because it’s pretty important to mathematics – but we won’t really get in to much of that in this post.
Remember the cups we talked about? Let’s go back to those and see if we can figure out the Fibonacci sequence. Now, the thing about recursive sequences is that you usually have to take at least one of the cups before the cup you’re working on, and use those numbers in your function. Let’s just take a look at it.
With this recursive sequence, we have the first two terms defined for us.
So, now that we have our first two cups filled up, we can start with our second cup, which would be . The sequence says , so basically what that means is that we fill up each cup with everything that was in the last two cups (because we’re adding – and adding is just like putting things together in a mixing bowl when you’re cooking).
So if n=2 (), then that means we need to take and (or the two cups right before cup “2”) and dump them into ‘s cup. =1 and =1, so when you dump those into a cup, you get 2, right? So =2. (I’ve made some illustrations for what’s happening.
Now for the third cup, , we dump in the last two cups, which are now cups 1 and 2. =1, and =2, so = 2 + 1 = 3. At first the Fibonacci sequences just looks like , but let’s just keep going.
We need cups “3” and “2” to fill up cup “4”. = 2, and = 3, so when we dump in those two cups we get = 3 + 2 = 5, so =5, and now we don’t have - we have Fibonacci!
When you write it out, it’s pretty easy to see what the next term will be:
Now I’m going to give you a few practice problems. I’ll post the answers tomorrow, to give you a chance to figure them out on your own.
Find the first 5 terms of each sequence.
(write your answers in the comment section, or email them, or post them on Twitter or Facebook. Those who come up with the correct answers before I post them tomorrow will be mentioned in the answers post)
If you have questions, you can ask them in the comments, email me, ask on Facebook, or on Twitter. I am on Facebook and Twitter live from 3:00-3:30 pm Mon-Thurs MDT.
No comments:
Post a Comment