Fórmula recursiva

Before this, knowEncontrando termos

Video · + 1 min read

(Video) Recursive Sequences

by PatrickJMT

This video by PatrickJMT talks about recursive sequences.

Summary\large{\text{Summary}}

A recursive sequence is kind of like a sequence that refers back to itself.

The first problem Patrick looks at is,

Find the first 33 terms of a sequence that has a first term of a1=4a_1=4 and nthn^{\text{th}} term: an=2an−1+3a_n=2a_{n-1}+3.

an=2an−1+3a_n=2a_{n-1}+3 is a recursive formula because each term, an,a_n, refers back to the previous term, an−1.a_{n-1}. This equation is telling us that whatever term we want to find is equal to 22 times the previous term, plus 3.3.

We're given the first term to start. a1=4a_1=4

To find the second term, we use our equation. an=2an−1+3a2=2a2−1+3a2=2a1+3a2=2(4)+3a2=11\begin{align} a_n&=2a_{n-1}+3\\ a_2&=2a_{2-1}+3\\ a_2&=2a_1+3\\ a_2&=2(\color{#29A603}{4})+3\\ a_2&=11 \end{align}

We use the same method to find the third term. an=2an−1+3a3=2a3−1+3a3=2a2+3a3=2(11)+3a3=25\begin{align} a_n&=2a_{n-1}+3\\ a_3&=2a_{3-1}+3\\ a_3&=2a_2+3\\ a_3&=2(\color{#29A603}{11})+3\\ a_3&=25 \end{align}

The first three terms of this sequence are: 4,11,254,11,25.

Try it Yourself!

Given a1=2a_1=2 and an=an−1(n+1n)a_n=a_{n-1}\left(\frac{n+1}{n}\right), find the first 55 terms of the sequence.

Choose one answer

Put ideas together

Contest problems often need this idea together with one or two others. That is where understanding goes deeper than memory. These are real problems from the AMC 8, AMC 12 and AIME, the national math competitions for middle and high school students, each with a worked solution on LIVE by Po-Shen Loh.

Read · 3 min

Recursive Formulas

Recursive formulas seem to show up everywhere we look, and they can be surprisingly useful. However, they can also be frustratingly mysterious.

A recursive formula relates the nthn^{\text{th}} term, or an,a_n, to previous terms like an−1,an−2,a_{n-1}, a_{n-2}, etc.

Recursive formulas show up everywhere, even in our day-to-day life. For example, suppose that you grew two inches each year. You could then describe your height on your nthn^{th} year as: hn=hn−1+2h_n=h_{n-1}+2

Simple, right? However, there are a few things that make recursive formulas more difficult than they might seem.

First is the need for initial conditions, also called base cases. Initial conditions are starting values in the sequence defined by the recursive formula. Without initial conditions, you can never know any of the terms in the sequence, because they could start anywhere.

In the above example, suppose you were born 88 inches tall, i.e., h0=8.h_0=8. Then you would be 1010 inches by age 1,1, and 1212 inches by age 2,2, and so on. However, you could have also been born 1010 inches tall, i.e., h0=10.h_0=10. Then you would be 1212 inches by age 1,1, and 1414 inches by age 2,2, and so on. Your starting height would change how tall you were at every age. Without a base case, the entries in a recursive sequence can't be determined.

Second, and more frustratingly, there is no set way to solve every recursive formula. (By "solving", we mean obtaining a formula for the nthn^{\text{th}} term that does not depend on any of the terms before it, except the base case. We would want to "solve" because finding the nthn^{\text{th}} term of a complicated recursive formula can be very tedious for a large nn.)

While the one above is pretty simple, many recursive formulas need very creative solutions, and some are completely unsolvable. However, there are some types of formulas that we know how to solve.

Solving a Simple Arithmetic Recursion

While there is unfortunately no method that can solve every recursive formula, it can be easy to solve simple arithmetic recursive formulas (which can describe arithmetic sequences). By "arithmetic recursive formula" we mean that the only operation involved is addition. The example above was an arithmetic recursive formula: hn=hn−1+2h_n=h_{n-1}+2

However, we're going to use a slightly more complicated answer, so we can illustrate the power of solving a recursive formula. Suppose that on day one, a company makes 11 dollar, and every day the company makes 2323 more dollars than the day before. We could describe their income on the nthn^{th} day as: an=an−1+23a_n=a_{n-1}+23

While it may be easy to calculate their profit for a few days or a week with the above formula, it would be difficult to estimate their profit after a few years. To do that, we have to solve it. We do this by listing some terms, finding the difference, d,d, between each term, and then fitting the final formula to the sequence. The formula to find the nthn^{\text{th}} term in an arithmetic sequence is: an=(n−1)d+a1a_n=(n-1)d+a_1

Let's try it. With the formula above, the first 55 terms are as follows: a1=1 (given to us as the base case)a2=a1+23=24a3=a2+23=47a4=a3+23=70a5=a4+23=93\begin{align} a_1 &= 1 \text{ (given to us as the base case)}\\ a_2&=a_1+23=24\\ a_3&=a_2+23=47\\ a_4&=a_3+23=70\\ a_5&=a_4+23=93 \end{align}

From there, we can easily see that the difference between each term is 23,23, and so we know dd. This is important, because we know that dd will appear as the coefficient on the nn term in the final formula.

We then have to fit this dd to the final formula. Since we know that the formula for the nthn^{\text{th}} term in an arithmetic sequence is an=(n−1)d+a1,a_n=(n-1)d+a_1, we can come up with the following formula to describe the sequence: an=23(n−1)+1a_n=23(n-1)+1

We now can easily find how much money the company will make in 10,100,1000,10, 100, 1000, or any other amount of days by substituting for n.n.

This formula is also interesting because it illustrates a pattern common to all arithmetic recursive formulas. We can see that our base case makes it into the final formula as the final term being added on, and given the initial formula, we can see that dd was there all along: an=an−1+23d is the term being addeda_n=a_{n-1}+{\color{#29A603}{23}}\quad d\text{ is the term being added}

With these two facts, we can find a general solution to a recursive formula of the form an=an−1+da_n=a_{n-1}+d with a1=ka_1=k, for any constant k:k: an=d(n−1)+ka_n=d(n-1)+k

To see this formula in action, try some examples for yourself!

Illustrated · 1 min

Maximum Depth Exceeded: Fun with Sequences and Python, Part 1

We're going to talk about sequences, specifically about the relationship between closed forms and recursive formulas for sequences. In fact we're going to do something extra special and use our friends from Python to guide us.

A recurrence formula lets us generate a sequence by finding the terms one by one until we get the term we want (many questions are worded "find the nthn^{\text{th}} term in this sequence if it's satisfied by this formula").

The formula is an equation, where one side is the current term we want to find out (usually written like ana_n), and it depends on earlier terms in the sequence.

One example is

an=an−1−1,a_n = a_{n - 1} - 1,

where we assume we KNOW what an−1a_{n - 1} is and then just plug it in the formula. Let's type this into a Python function, shown below.

define the Python function a(n) so that a(n) = a(n - 1) - 1

Image source: By Joshua Siktar

We can't seem to find a(10)

Image source: By Joshua Siktar

Well we tried to find a10a_{10} and we failed. What gives? We keep moving backwards in the sequence to find a term that we actually KNOW the value of, but we aren't given any. For instance, we are usually told a0a_0 to make the recurrence formula useful. If a0=7a_0 = 7 rewrite our Python code is as follows:

If n = 0 then a(0) = 7, otherwise use the same formula as before.

Image source: By Joshua Siktar

Now if we try to find a10a_{10} we get a result we expect:

a(10) = -3

Image source: By Joshua Siktar

Much better!

If you want to see the next part of this Python story, go here.

Illustrated · 2 min

Recursive Sequences

Recursive sequences are sequences defined by recursive formulas. They are also called recurrence relations or recurrence equations.

A recursive formula relates each term in the sequence to previous terms in the sequence. This is different than an explicit formula, which describes each term in the sequence as a function of its position.

Let's look at the Fibonacci sequence.

Recursive Sequence: ordered list of objects, repetition is allowed, finite or infinite, defined by a recursive formula. Example: the Fibonacci Sequence: 0, 1, 1, 2, 3, 5, 8, 13, ...The recursive formula is F_n=F_(n-1)+F_(n-2), with F_0=0 and F_1=1.

Image source: By Caroline Kulczycky

Let's break down the recursive formula for the Fibonacci sequence.

Fn=Fn−1+Fn−2Initial conditions:F0=0,F1=1\begin{align} F_n&=F_{n-1}+F_{n-2}\\ \text{Initial conditions}&: F_0=0, F_1=1 \end{align}

Fn=Fn−1+Fn−2F_n=F_{n-1}+F_{n-2} means that each term (Fn)(F_n) is equal to the sum of the previous term (Fn−1)(F_{n-1}) and the term before the previous term (Fn−2).(F_{n-2}). We include initial conditions so the sequence has a place to start. Initial conditions are the first few terms in the sequence. Recursive sequences need initial conditions to define a starting point.

Let's check that this Fibonacci recurrence relation is correct. We know that our first couple terms are defined by the initial conditions F0=0F_0=0 and F1=1.F_1=1. So, let's start at the next term!

The next term is F2,F_2, and F2=1.F_2=1. The term before F2F_2 is F1=1,F_1=1, and the term before that is F0=0.F_0=0. Using our recurrence formula: Fn=Fn−1+Fn−2F2=F2−1+F2−2F2=F1+F01=1+01=1✓\begin{align} F_n&=F_{n-1}+F_{n-2}\\ F_2&=F_{2-1}+F_{2-2}\\ F_2&=F_{1}+F_{0}\\ 1&=1+0\\ 1&=1 \checkmark \\ \end{align}

The next term is F3,F_3, and F2=2.F_2=2. The term before F3F_3 is F2=1,F_2=1, and the term before that is F1=1.F_1=1. Using our recurrence formula: Fn=Fn−1+Fn−2F3=F3−1+F3−2F3=F2+F12=1+12=2✓\begin{align} F_n&=F_{n-1}+F_{n-2}\\ F_3&=F_{3-1}+F_{3-2}\\ F_3&=F_{2}+F_{1}\\ 2&=1+1\\ 2&=2 \checkmark \\ \end{align}

The next term is F4,F_4, and F4=3.F_4=3. The term before F4F_4 is F3=2,F_3=2, and the term before that is F2=1.F_2=1. Using our recurrence formula: Fn=Fn−1+Fn−2F4=F4−1+F4−2F4=F3+F23=2+13=3✓\begin{align} F_n&=F_{n-1}+F_{n-2}\\ F_4&=F_{4-1}+F_{4-2}\\ F_4&=F_{3}+F_{2}\\ 3&=2+1\\ 3&=3 \checkmark \\ \end{align}

Let's do one last one! The next term is F5,F_5, and F5=5.F_5=5. The term before F5F_5 is F4=3,F_4=3, and the term before that is F3=2.F_3=2. Using our recurrence formula: Fn=Fn−1+Fn−2F5=F5−1+F5−2F5=F4+F35=3+25=5✓\begin{align} F_n&=F_{n-1}+F_{n-2}\\ F_5&=F_{5-1}+F_{5-2}\\ F_5&=F_{4}+F_{3}\\ 5&=3+2\\ 5&=5 \checkmark \\ \end{align}

Try the rest on your own!

Another Example

Let's figure out the first four terms of the geometric sequence defined by the following recurrence relation and initial conditions: an=4an−1Initial conditions:a1=−1\begin{align} a_n&=4a_{n-1}\\ \text{Initial conditions}&: a_1=-1 \end{align}

We know that our first term is defined by the initial conditions a1=−1.a_1=-1. So, let's start at the next term!

The next term is a2.a_2. the term before a2a_2 is a1,a_1, and a1=−1.a_1=-1. Using our recurrence formula: an=4an−1a2=4a2−1a2=4a1a2=4(−1)a2=−4\begin{align} a_n&=4a_{n-1}\\ a_2&=4a_{2-1}\\ a_2&=4a_{1}\\ a_2&=4(-1)\\ a_2&=\boxed{-4}\\ \end{align}

The next term is a3.a_3. the term before a3a_3 is a2,a_2, and a2=−4.a_2=-4. Using our recurrence formula: an=4an−1a3=4a3−1a3=4a2a3=4(−4)a3=−16\begin{align} a_n&=4a_{n-1}\\ a_3&=4a_{3-1}\\ a_3&=4a_{2}\\ a_3&=4(-4)\\ a_3&=\boxed{-16}\\ \end{align}

Last one! The next term is a4.a_4. the term before a4a_4 is a3,a_3, and a3=−16.a_3=-16. Using our recurrence formula: an=4an−1a4=4a4−1a4=4a3a4=4(−16)a4=−64\begin{align} a_n&=4a_{n-1}\\ a_4&=4a_{4-1}\\ a_4&=4a_{3}\\ a_4&=4(-16)\\ a_4&=\boxed{-64}\\ \end{align}

So, the first four terms in the sequence defined by this recurrence relation are: −1,−4,−16,−64...-1, -4, -16, -64 ...

Here is more on formulas for geometric sequences, if you are interested.

Type a concept, like “slope” or “photosynthesis”.

↑ ↓ to choose · Enter to openSearch explanations and problems