Skip to main content

Section A.14 Recursive functions

We often use subscript notation when the function is a recursive function, where we rely on knowing previous values in order to compute the next value, as in the example below. Example: Suppose \(a_{n+1} = 3a_{n} + 2\) and \(a_0 = 3.\)

Checkpoint 361.

Find the value of \(a_1.\)
Answer.
One way to read this definition is: ``To get the next value of \(a\)--the value at \(n+1,\) we take 3 times the previous value of \(a\)--the value at \(n\)--and then add two. In this example, we know the value of \(a\) at \(n=0,\) because we are given that \(a_0 = 3.\) Then we can find the next value of \(a\)--the value at \(n = 1\)--as follows:
\begin{align*} a_1 \amp = 3a_0 + 2\\ \amp = 3\cdot 3 + 2\\ \amp = 11. \end{align*}

Checkpoint 362.

Find the value of \(a_4.\)
Answer.
If we use the formula above, with \(n = 3,\) then we have
\begin{equation*} a_{4} = 3a_{3} + 2. \end{equation*}
It looks like we actually need to know the value of \(a_3\text{...}\)and it turns out that in order to know the value of \(a_3\) we actually need to know the value of \(a_2\text{...}\)which requires that we know the value of \(a_1\)--which we already found. So here goes:
\begin{align*} a_2 \amp = 3a_1 + 2\\ \amp = 3\cdot 11 + 2\\ \amp = 35\\ \amp\\ a_3 \amp = 3a_2 + 2\\ \amp = 3\cdot 35 + 2\\ \amp = 107\\ \amp\\ a_4 \amp = 3a_3 + 2\\ \amp = 3\cdot 107 + 2\\ \amp = 323. \end{align*}
The bottom line with recursive functions is that if we know \(a_0,\) we can find \(a_1,\) and then we can find \(a_2,\) and so on. But if we want to know \(a_{17},\) for example, we need to know ALL of the previous \(a\)-values \(a_0, a_1, a_2, \ldots , a_{16}\text{.}\)

Remark 363.

You may recall some of this from studying sequences and series in calculus. In calculus we sometimes looked for a pattern so we could avoid having to compute all previous values. Thatโ€™s a great skill, and it might even work for the examples below, but we wonโ€™t generally be able to do that in differential equations.
Now you try:

Exercises Exercises

Given the definition of a recursive function in subscript notation, find the value of the given term.
You have attempted of activities on this page.