If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains ***.kastatic.org** and ***.kasandbox.org** are unblocked.

Main content

Current time:0:00Total duration:9:07

CCSS.Math:

so we've got the function G here what I want you to do is pause the video and figure out what G of 1 is figure out what G of 2 is G of 3 and G of 4 figure out what all four of these are alright now let's work through this together so G of 1 if n is equal to 1 well then we're going to hit this case right over here if n is equal to 1 G is equal to 4 so that was pretty straightforward now G of 2 G of 2 if n is equal to 2 well that's n is 2 is greater than 1 and it's a whole number and so we would use this case so this is interesting because it's defined in terms of the function but it's not defined in terms of G of n but G of n minus 1 so if n is 2 because we're evaluating G of 2 here this is going to be G of 2 minus 1 or G of 1 plus 3.2 plus 3.2 well what's that going to be well G of 1 we know is equal to 4 we just figured that out so 4 plus 3 point 2 that is 7 point 2 all right let's keep going G of 3 we're going to fall into this case again because 3 is greater than 1 and it's a whole number so this is going to be G of 3 minus 1 or G of 2 plus 3 point 2 plus 3 point 2 well we know what G of 2 is it's 7 point 2 we just figure that out it is seven point two seven point two plus three point two is going to be equal to 10 point four and then G of 4 well we fall here again this is going to be G of three plus three point two G of 3 plus three point two what is that going to be equal to well G of three we just figured out is ten point four ten point four plus three point two is going to be thirteen point six and so what you have here this is actually quite interesting you can think of this this function and dysfunction Jean you see that it's defined over all positive integers because it's defined over positive integers we could think of it as defining a sequence and we see what the sequence here is the first term first term is for second term is 7.2 next term is 10.4 next term is 13.6 and it could keep going on and on and on and what's happening what's happening in the sequence well we're starting with four we're starting with four and that's this case of the function gave us that if n is equal to four is your if n is n is equal to 1 the function is going to be equal to 4 and then for each term after that you take the previous term and you add 3.2 so we add 3.2 for the second term we add 3.2 so we just keep adding we just keep adding three point three point two nine point three two three point two to get to the next term now we could have defined it that way because hey let's have a sequence for the first term is four then we keep adding three point two to get each next term but this is another interesting way to find it defining it in this way of defining it where we defined it as an algebraic function a function that's defined over all positive integers where we have a base case and the base case really in this case gave us our first term and then we have this other case that's defined in terms of the function then you have to recurse backwards to eventually get to a base case we call this a recursive function a recursive recursive function so with this example we're seeing how a recursive function can be used to define an actual sequence and you know you could we went in order here but you could have gone the other way around if I said oh well what's a what's G of what's G of six well you go into this case you would say okay that's going to be G of 5 plus 3.2 it's going to be the previous term plus 3 point plus 3.2 if we view it if we view it as a sequence well then we're going to figure out what the previous term is G of 5 is going to be G of 4 G of 4 plus 3.2 and you would keep going back and back and back but we've already figured out what G of 4 is it's thirteen point six thirteen point six so this is 16.8 and then if G of 5 is 16 twenty-eight 16.8 yet 3.2 there you would get 20 so you could start at go6 and keep backing up all the way until you get to G of one and then you figure out what that is you get you could recurse back to your base case and then you're able to to fill in all the blanks so let's do a few more examples of this so we have this function here so let's say that this defines a sequence let's think about what the first four terms of that sequence are and once again I encourage you to pause the video and figure that out alright let's work through it so H of one is well they very clearly tell us that's going to be 14 if n is equal to 1 H is 14 H of 2 H of 2 well now we're falling into this case because 2 is greater than 1 and it's a whole number so it's going to be 28 over H of 1 over H of 1 well we know H of 1 is 14 so it's going to be 28 over 14 which is equal to 2 now H of 3 H of 3 we're going to fall into this case again it's going to be 28 28 divided by H of 2 for thinking of this as a sequence divided by the previous term in the sequence so 28 divided by H of 2 we know that H of 2 is equal to is equal to 2 we just figure that out so we go back to 14 something very interesting I think you see where this is going H of 4 is going to be 28 divided by H of 3 28 divided by H of 3 which is 28 divided by this is H of 3 right over here we just figured that out divided by 14 which is back to 2 if we were to if we were to think of this as a sequence we'd say all right let's see we the first term is 14 then we get 2 then we get to 2 then we go to 14 then we get to 2 so one way to think about this sequence is that we just keep alternating between 14 and twos all of the odd terms of the sequence are 14 all of the even terms of the sequence or two that's one way to think about it or another way to think about it is we're starting with 14 and each successive term is the pre is term divided is 28 divided by the previous term so here 28 divided by 14 is 2 28 divided by 2 is 14 28 divided by 14 is 2 and we keep going on and on and on and that's what was actually going on right over there let's do one more of these and this one is interesting because we now have we now have 2 we now have two base cases so let's think about this this is and actually let's just let's just say we wanted to figure out we wanted to figure out what what f of 4 is f of 4 well we're going to fall into this case 4 is greater than 2 and it's a whole number it's going to be F of 4 minus 2 so it's going to be F of 2 plus F of 4 minus 1 plus F of 3 so F of 4 is going to be the sum of the preceding two numbers all right so let's figure out what F of 3 is going to be F of 3 we fall into this case again it's going to be F of 3 minus 2 is F of 1 plus F of 3 minus 1 plus F of 2 the sum of the preceding two numbers so let's figure out what F of 2 is going to be well now we're not doing the sum of the preceding two numbers anymore we fall into this base case n is now equal to 2 it's going to be equal to negative 4 and we're going to figure out what F of 1 is as well and we see when N is equal to 1 F is equal to negative 6 we have two base cases right over here base base cases cases that aren't defined in terms of the function itself and you need that because otherwise you just be recursing forever you would never get to actual numbers but now we can use these to fill in the values up here so the sequence is negative 6 then we go to negative 4 as the second term and then the third term is the sum of the previous two negative 4 plus the negative 6 plus negative 4 is negative 10 negative 6 plus negative 4 is negative 10 and then the fourth term is the sum of the previous two we see it right over here the second term F of 2 plus F of 3 negative 4 plus negative 10 is negative 14 and we could keep going on and on and on like that so so right over here is negative 14 so the whole point of this video you're a little bit familiar with recursive functions now and also you can see how these can be used to define actual sequences