Академический Документы
Профессиональный Документы
Культура Документы
An important idea in mathematics is to establish connections between two fields in order to apply
knowledge in one field to the other field, or at least take a problem in one field and transform it to a problem
in the other field. This idea motivates the idea of a generating function, which establishes a connection
between functions of a real variable and sequences of numbers.
Example: The generating function for the constant sequence , has closed
form
This is because the sum of the geometric series is (for all x less than 1
in absolute value).
> f(x) =sum(x^'i','i'=0..infinity);
>
Problem: Find a formula for the nth term of the sequence defined by , and .
Investigation. This rule is directly programmable in Maple, using a recursive program (g refers to itself in
its definition).
> g := proc(n) options remember; if n = 0 then 1 else 5*g(n-1) - 3 fi end;
> g(100);
> seq(a[n]=g(n),n=0..10);
>
A Solution using generating functions.
= =
Doing a partial fraction decomposition of the right hand side
> convert((1-4*x)/((1-5*x)*(1-x)),parfrac,x);
f(x) =
f(x) =
> seq(k(n),n=0..10);
> seq(g(n),n=0..10);
> seq(p(n),n=0..10);
Actually, DeMoivre introduced the notion of generating function in 1730 to solve recurrence relations. Here
is a famous one first defined by Fibonacci in 1200.
The way to see this is to think of how the coefficient of in the expansion of is made up. The
expansion of has terms before collecting is done. Each term is a product n things some of
which are x's and the rest 1's. The coefficient of is the number of those terms which has exactly r x's.
We can program this directly in Maple.
> binom := proc(n,r)
local x,cof;
if r = 0 or r=n then 1 else
coeff( expand( (1+x)^n),x,r) ;
fi end:
> seq(binom(4,i),i=0..4);
So, for example, the number of ways to choose 10 books from a library of 40 books is
> binom(40,10);
Same result.
Problem. How many Lotto tickets have only even numbers? prime numbers?
Problem . Show that for all positive integers n and r with r < n, .
Second Solution: Choose 2 of the 5 blacks, then choose 2 of the 4 reds, and last choose 2 of the 3 yellows.
This gives
> binom(5,2)*binom(4,2)*binom(3,2);
Problem. A library has 5 indistinguishable black books, 4 indistinguishable red books, and 3
indistinguishable yellow books. How many distinguishable ways can a student take home 6 books, 2 of each
color?
Solution 1 . The student chooses 2 black books (only one way to do that since the black books are
indistinguishable) then 2 reds then 2 yellows. The set of things we are counting is the cartesian product of
three sets each with 1 element, so the answer is 1.
Solution 2. Think of choosing the black books first: since they are indistinguishable amonst each other, the
only distinguishing characteristic of the choice is the number of black books chosen. We could represent this
of is 1 which is the number of ways to take home 6 books, two of each color.
Problem. A library has 5 indistinguishable black books, 4 indistinguishable red books, and 3
indistinguishable yellow books. How many distinguishable ways can a student take home 6 books, at least 1
of each color?
Solution 1. Direct count. Make a list. of the triples [x,y,z] of integers satisfying x+y+z = 6, 1<= x <=5, 1 <=
y <= 4, and 1 <= z <= 4. [4,1,1], [3,2,1],[3,1,2], [2,3,1],[2,2,2],[2,1,3], [1,2,3],[1,3,2],[1,4,1]. There are 9.
>
Solution 2. As above, we can form a polynomial p
least one of each color. If we set x = y = z in p and collect like terms then the coefficient of is the
desired answer.
> p := (x+x^2+x^3+x^4+x^5)*(y+y^2+y^3+y^4)*(z+z^2+z^3);
> q :=subs({y=x,z=x},p);
> coeff(q,x^6);
>
Problem. A library has 5 indistinguishable black books, 4 indistinguishable red books, and 3
indistinguishable yellow books. How many distinguishable ways can a student take home 6 books?
Solution 1. Direct count. Make a list. of the triples [x,y,z] of integers satisfying x+y+z = 6, 0<= x <=5, 0 <=
y <= 4, and 0 <= z <= 4.
Solution 2. Polynomial solution.
> p := (1+x+x^2+x^3+x^4+x^5)*(1+y+y^2+y^3+y^4)*(1+z+z^2+z^3);
> q :=subs({y=x,z=x},p);
>
> coeff(q,x^6);
Partial-Fraction Decomposition:
General Techniques (page 1 of 3)
Partial-fraction decomposition is the process of starting with the simplified answer and taking it back apart,
of "decomposing" the final expression into its initial polynomial fractions.
To decompose a fraction, you first factor the denominator. Let's work backwards from the example above.
The denominator is x2 + x, which factors as x(x + 1).
Then you write the fractions with one of the factors for each of the denominators. Of course, you don't know
what the numerators are yet, so you assign variables (usually capital letters) for these unknown values:
Multiply things out, and group the x-terms and the constant terms:
3x + 2 = Ax + A1 + Bx
3x + 2 = (A + B)x + (A)1 ADVERTISEMENT
(3)x + (2)1 = (A + B)x + (A)1
3=A+B
2=A
A=2
B=1
Then the original fractions were (as we already know) the following:
Like this:
= 2x+2 + 3x6x2+x2x2
= 5x4x2x2
This can help solve the more complicated fraction. For example it is very useful in Integral Calculus.
The method is called "Partial Fraction Decomposition", and goes like this:
Firstly, this only works for Proper Rational Expressions, where the degree of the top is less thanthe bottom.
Proper: the degree of the top is less than the degree of the bottom.
degree of top is 1
Proper:
degree of bottom is 3
Improper: the degree of the top is greater than, or equal to, the degree of the bottom.
degree of top is 2
Improper:
degree of bottom is 1
Example: (x2-4)(x2+4)
(x-2)(x+2)(x2+4)
linear factors
irreducible quadratic factors
When you have a quadratic factor you need to include this partial fraction:
Sometimes you may get a factor with an exponent, like (x-2)3 ...
Like this:
Example:
1(x2)3
Example:
1(x2+2x+3)2
Even after using the roots (zeros) of the bottom you can end up with unknown constants.
Gather all powers of x together and then solve it as a system of linear equations.
Oh my gosh! That is a lot to handle! So, on with an example to help you understand:
x2+15(x+3)2 (x2+3)
Because (x+3)2 has an exponent of 2, it needs two terms (A1 and A2).
And (x2+3) is a quadratic, so it will need Bx + C:
(-3)2+15 = 0 + ((-3)2+3)A2 + 0
24 = 12A2
so A2=2
x3: 0 = A1+B
x2: 1 = 3A1+6B+C+2
x: 0 = 3A1+9B+6C
Constants: 15 = 9A1+6+9C
0 = A1 + B
-1 = 3A1 + 6B + C
0 = 3A1 + 9B + 6C
1 = A1 + C
Now solve.
You can choose your own way to solve this ... I decided to subtract the 4th equation from the 2nd to begin with:
0 = A1 + B
-2 = 2A1 + 6B
0 = 3A1 + 9B + 6C
1 = A1 + C
0 = A1 + B
-2 = 4B
0 = 3A1 + 9B + 6C
1 = A1 + C
Final Result:
Recurrence Relations
We talked about recursively-defined sequences earlier.
o Like the Fibonacci Sequence: f0=0, f1=1, fn=fn1+fn2.
o The last part of that, where the next term depends on
previous ones is called a recurrence relation.
o A solution is an=2n1.
o You can only move one disk at a time, and cannot put a
larger disk on a smaller one.
Hn=2Hn1+1=4Hn2+2+1=8Hn3+4+2+1=2n1H1+2n2+2n3++
4+2+1=2n1+2n2+2n3++4+2+1=2n1.
Hn=2Hn1+1=2(2n11)+1=2n1.
an=c1an1+c2an2++ckank.
an=c1an1+c2an2++ckank,
rn=an=c1rn1+c2rn2++ck+1rn(k+1)+ckrnk.
rnc1rn1c2rn2ck+1rn
(k+1)ckrnk=0rkc1rk1c2rk2ck+1rck=0.
an=c1an1+c2an2++ckank,
rkc1rk1c2rk2ck+1rck=0.
If the equation has k distinct roots, r1,r2,,rk, then {an} is a
solution to the recurrence relation if and only if
an=d1rn1+d2rn2++dkrnk,
a0=d130+d2(1)0=d1+d2=3,a1=d131+d2(1)1=3d1d2=5.
Adding these equations, we get 4d1=8, so d1=2. And then from the
first equation, we have d2=1.
f0f1=d1+d2=0,=d11+52+d2152=1.
an=c1an1+c2an2++ckank+F(n).
hn=c1hn1+c2hn2++ckhnk.
pncn+dcn+d0=3pn1+2n=3(c(n1)+d)
+2n=3cn3c+3d+2n=(2c+2)n+(2d3c).
This is true for all n iff 2c+2=0 and 2d3c=0. Solving these, we
get c=1 and d=3/2.
anpn=c1(an1pn1)+c2(an2pn2)++ck(ankpnk)
So, any solution {an} is can be written in the form {pn+hn} for
some solution to the homogenous recurrence.
Returning to our example, we wanted an=3an1+2n with a1=3 and
had hn=d3n and pn=n3/2.
o The above theorem tells us that all solutions to the
recurrence look like an=d3nn3/2.
a1d3113/2d=3=3=11/6.
pnc3nc(3n23n1)c(32)c=2pn1+3n=2(c3n1)+3n=3n=3n/3n1=3.
an5=a15d=d2n+3n+1=d21+32=2d+3=2.
o So, an=2n+1+3n+1.
Example: One more. Find a solution
for an=5an1+6an2+7n with a0=1 and a1=6.
o The homogeneous part has characteristic
equation r25r6=0, so roots r1=6,r2=1.
pn=c7nc720=5c7n1+6c7n2+7n=5c71+6c70+72=49/8.
o So we have pn=4987n.
o From the theorem,
an=d16n+d2(1)n+4987n.
an=66n78(1)n+4987n=18(86n+17(1)n+7n+2).
Divide-and-Conquer Relations
Many recursive algorithms are divide-and-conquer algorithms.
o That is, they split the problem into pieces (divide), and
recurse on those pieces to solve the problem (conquer).
f(n)=af(n/b)+cnd,