Download Project 2 Caty Duncan

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Location arithmetic wikipedia , lookup

Elementary mathematics wikipedia , lookup

Proofs of Fermat's little theorem wikipedia , lookup

Transcript
Project 2
Caty Duncan
Part 1:
1. THE CENTRAL BINOMIAL COEFFICENT

Background (See also Doerr & Levasseur, Chapter 8, section 1)

Specifics:

The binomial coefficients
are defined recursively as follows:
1.
for all integers
2.
for all integers
3.
for all integers

Plot the central binomial coefficient

Find upper bounds for, or determine, the rate of growth of
as a function of
for
as a function of
.
The binomial coefficients equation can be completed by hand for small numbers such as 2 as
seen in the figure below:
The central binomial coefficient can be plotted in Mathmatica using the following commands:
T[n_,k_]:=T[n,k]=ReleaseHold[binexp[n-1,k]+T[n-1,k-1]];
T[n_,0]=1;
T[0,k_]=0;
A=Table[{n,T[2 n,n]},{n,0,25}];
B=ListPlot[A]
This set of code yields the following plot:
12
1.2
10
1.0
10 12
8.0
10 11
6.0
10 11
4.0
10
2.0
10 11
11
5
10
15
20
25
It appears as though the plot is exponential. The values increase with greater magnitude after
each value. To double check if this is in face exponential the following Mathmatica commands
can be used:
ListLogPlot[𝐴]
Which yields the following plot:
10
12
10 9
10 6
1000
5

10
15
20
25
Imagine walking on the grid below, from the red dot (the “origin”) to any other dot by
walking UP one step or RIGHT one step at a time:

Show that the number of different paths from the origin to a dot that is k steps UP and n-k steps
RIGHT (or vice versa),where
, is
If you start with a smaller grid, it is easier to list the number of different paths to get to any
particular box by only moving up or to the right.
1
1
1
0
4
3
2
1
10 20
6 10
3 4
1 1
It is easy to see that there is only one path to any of the points directly above or directly to the
right of the starting point. The other points are more difficult to determine because you can enter
the point from the point below or to the left of the desired ending point.
The further away you move from the origin the more options there are for paths to achieve that
position. Once you create a small chart with all of the possible paths listed in the square a pattern
arises. If you add the number below and to the left of the desired square you will get the number
of paths to get to the desired square. For example, in the diagram above, if you take the number 6
you see that the square below it contains a 3 and the square to the left of it contains a 3 as well. If
you add those two numbers you get the total number of paths to get to that particular position, in
this case 6.

For the dots that are 15 steps away from the origin calculate how many different paths there are
to that dot.

Use Mathematica to expand
a coincidence?

What is special about “15″?
and examine the coefficients of the powers
. Is this
Expand[(𝑎 + 𝑏)^15]
𝑎15 + 15𝑎14 𝑏 + 105𝑎13 𝑏 2 + 455𝑎12 𝑏 3 + 1365𝑎11 𝑏 4 + 3003𝑎10 𝑏 5 + 5005𝑎9 𝑏 6 + 6435𝑎8 𝑏 7
+ 6435𝑎7 𝑏 8 + 5005𝑎6 𝑏 9 + 3003𝑎5 𝑏10 + 1365𝑎4 𝑏11 + 455𝑎3 𝑏12 + 105𝑎2 𝑏13
+ 15𝑎𝑏14 + 𝑏15
If you expand the mathmatica command (a+b)^15 you get the above output. If you then add all
of the numbers you will get the total number of possible paths to that point. There are 32,768
different paths to get to the specified point. Fifteen is significant because the coefficients match
on either side of the equation.

A block tower of 2 colors is built as a vertical stack of blocks, with a bottom and a top. Below are
several block towers of height 5:

How many block towers of height 5 are there and what are they?


What does this have to do with the binomial expansion of

What connection is there between block towers of height n, the binomial expansion
?
What does it have to do with the number of walks on the grid, above, to points that are 5 steps
from the origin?
of
and walks on the grid to points that are n steps from the origin?
If you do the block diagrams out as seen on the top of the figure below there are 32 possible
towers made of five blocks.
Much like walking on the origin there are two possible moves, one being a black block one being
a white block. In the case of moving five spaces away from the origin there are 32 possible paths.
The connections between block towers of height n and the binomial expansion lie in the
coefficients. If you add the coefficients of the binomial expansion you will get the number of
paths that you can take to get to that possible position. This is illustrated in the lower portion of
the figure above. Adding the coefficients for the expansion of 5 equals 32.
2. DIJKSTRA’S FUSC FUNCTION

Background
fusc(n) = fusc(n/2) if n is even, and
fusc(n ) = fusc((n-1)/2) + fusc((n+1)/2) if n is odd,
with fusc(0) = 0 and fusc(1) = 1.


Plot fusc(n) as a function of n up to 10,000

Write the statement
Plot a table of values of fusc(n) alongside n for n up to 99. Verify from the table that for n <
100, fusc(n) is a multiple of 2 exactly when is a multiple of 3.
“For all n, fusc(n)is a multiple of 2 exactly when is a multiple of 3” ………(*)
in first-order logic. (see here for more on quantification).

Prove the statement (*) above is true:

First prove that if n is a multiple of 3 then fusc(n) is a multiple of 2. Do this by
splitting int0 two cases: (1) n is twice an even number (2) n is twice an odd number.
Utilize induction.

Second, prove that If is a not a multiple of 3 then fusc(n)is not a multiple of 2.
Consider the two ways in which an integer is not a multiple of 3 and use induction.
fusc[n_]:=If[Mod[n,2]==0,fusc[n/2],fusc[(n1)/2]+fusc[(n+1)/2]];
fusc[0]=0;
fusc[1]=1;
A=Table[{n,fusc[n]},{n,0,10000}];
ListPlot[A]
500
400
300
200
100
2000
4000
6000
8000
10000
A sample of the output table can be seen below:
3. FIBONACCI NUMBERS
The Fibonacci numbers
are determined by the following recursive relation:
Use Mathematica to calculate and plot
Estimate the growth rate of
Use the fact that if
then
more precise estimate of the growth rate of







f[0]=1;
f[1]=1;
f[n_]:=f[n]=f[n-1]+f[n-2];
T=Table[f[n],{n,0,50}]
ListPlot[𝑇]
1
10 9
8
10 8
6
10 8
4
10
2
10
8
8
10
20
30
40
50
ListLogPlot[𝑇]
10 10
10 8
10
6
10 4
100
10
20
30
40
50
to get a
.
The function is linear on the log plot so we can assume that it is an exponential function.
To more accurately figure out the growth rate you can use the following commands:
r[0]=1;
r[n_]:=1+1/r[n-1];
x=Table[r[n],{n,0,50}];
ListLogPlot[x]
1.5
10
20
30
40
50
Using this plot you can see the growth rate clearly. It is about 1.6 in this case.
4. GENERATING PRIMES

Background. The recursively defined sequence
a(n)=a(n-1)+GCD(n,a(n-1)), a(1)=7
has the remarkable property that the difference
g(n):=a(n)-a(n-1), n>1
is either 1 or a prime number: A NATURAL PRIME-GENERATING RECURRENCE _ROWLAND

Specifics:

For successive values of the integer n, compute the number dp(n) of distinct primes
generated as

, that are less than or equal to n.
Plot dp(n) as a function of n. What properties does this function have? Increasing, one-toone, onto?
a[n_]:=a[n]=a[n-1]+GCD[n,a[n-1]];
a[1]=7;
g[n_]:=a[n]-a[n-1]/;n>1;
Table[g[k],{k,2,100}]
This function is super inefficient and takes a long time to run. Although it does generate random
numbers there are easier ways to do so while decreasing the overall runtime.