maths.free › Combinatorics & Graph Theory › Recurrence Equations › Using generating functions to solve recurrences

Using generating functions to solve recurrences

The approach we have seen thus far in this chapter is not the only way to solve recurrence equations. Additionally, it really only applies to linear recurrence equations with constant coefficients.

Using generating functions to solve recurrences

The approach we have seen thus far in this chapter is not the only way to solve recurrence equations. Additionally, it really only applies to linear recurrence equations with constant coefficients. In the remainder of the chapter, we will look at some examples of how generating functions can be used as another tool for solving recurrence equations. In this section, our focus will be on linear recurrence equations. In , we will see how generating functions can solve a nonlinear recurrence.

Our first example is the homogeneous recurrence that corresponds to the advancement operator equation in .

Example

Consider the recurrence equation \(r_{n}+r_{n-1}-6r_{n-2} = 0\) for the sequence \(\{r_n\colon n\geq 0\}\) with \(r_0=1\) and \(r_1=3\). This sequence has generating function \[\begin{aligned}\end{aligned}\] Now consider for a moment what the function \(xf(x)\) looks like. It has \(r_{n-1}\) as the coefficient on \(x_n\). Similarly, in the function \(-6x^2 f(x)\), the coefficient on \(x^n\) is \(-6r_{n-2}\).

What is our point in all of this? Well, if we add them all up, notice what happens. The coefficient on \(x_n\) becomes \(r_n+r_{n-1}-6r_{n-2}\), which is \(0\) because of the recurrence equation! Now let's see how this all lines up: \[\begin{aligned}f(x) \amp = r_0 + r_1 x + r_2x^2 + r_3 x^3 + \cdots + r_nx^n + \cdots \\ xf(x) \amp = 0 + r_0 x + r_1x^2 + r_2 x^3 + \cdots r_{n-1}x^n + \cdots \\ -6x^2f(x) \amp = 0 + 0 -6r_0x^2 - 6r_1 x^3 + \cdots - 6r_{n-2}x^n + \cdots\end{aligned}\] When we add the left-hand side, we get \(f(x)(1+x-6x^2)\). On the right-hand side, the coefficient on \(x^n\) for \(n\geq 2\) is \(0\) because of the recurrence equation. However, we are left with \(r_0 + (r_0+r_1)x = 1 + 4x\), using the initial conditions. Thus, we have the equation \[\begin{aligned}\end{aligned}\] or \(f(x) = (1+4x)/(1+x-6x^2)\). This is a generating function that we can attack using partial fractions in SageMath:

This shows us that \[\begin{aligned}\end{aligned}\]. From here, we read off \(r_n\) as the coefficient on \(x^n\) and have \(r_n = (6/5) 2^n -(1/5)(-3)^n\).

Although there's a bit more work involved, this method can be used to solve nonhomogeneous recurrence equations as well, as the next example illustrates.

Condensed: the full section is in Keller & Trotter, Applied Combinatorics.

Haddaad Ma jiro xisaabis oo ku nool midkan, laakiin qaybaha ka mid ah waa la xisaabi karaa. Ku raaxayso mid ka hooseeya, ama ku qor adiga kuu gaar ah.

Ku hay shaqadaada

A xisaab bilaash ah oo ku daray qoraalada waxbarasho kasta, diiwaanka waxa aad dhamaatay, dhibaatooyinka aad xal u tahay meel kaliya, iyo macallinka aad weydiisan kartaa oo ku saabsan bogga. Xisaabta oo keliya waa u furan yahay qof kasta, la diiwaan geliyey ama aan.

Ku soo biir Ku soo gal

Calaamadaha la isticmaalay halkan

Taab calaamad kasta oo loogu talagalay qeexidda buuxda, sawir, iyo waxa xarfaha oo dhan ka mid ah ka dhigan tahay.

Su'aalaha dadku waydiiyaan

Permutation or combination?

Ask whether order matters. A lock code is a permutation (order matters); a hand of cards is a combination (it does not).

What is a graph in this sense?

Dots (vertices) joined by lines (edges), not a plot. Road maps, social networks and molecules are graphs; questions like "is there a route" and "how few colours" are graph theory.

Qaybaha ee boggaan waxaa la beddelay ka Keller & Trotter, Applied Combinatorics (CC BY-SA 4.0). Condensed iyo dib-oo halkan lagu sharaxay; khaladaadka waa inoo.

In ka badan Combinatorics & Graph Theory