Vous êtes sur la page 1sur 7

Assignment 1

August 17, 2018

1 Information
• Rationale for the assignment: This assignment has several objectives:

– To make you more comfortable with using SageMath and Jupyter Notebook.
– To enhance your understanding of linear recurrences and propositional logic.
– To improve your abilities to read and write mathematical text.

• Deadline: Assignment is due by 11:55 p.m. on Friday, August 31, 2018. It is your responsi-
bility to submit the assignment before the deadline on Moodle. E-mail submissions and
submissions in the wrong format will not be graded (you will get a zero).

• What to submit: For this assignment, you should submit a document in the iPython note-
book (.ipynb) format.

• Marking Scheme: There will be four assignments in this course. The best three will con-
tribute 12% each to your final course grade.

– This assignment will be graded out of 60 points. Points corresponding to each question
are indicated.
– Bonus points can help you score better on this assignment. The sum of points corre-
sponding to the six questions is 70. Your score out of 70 will be taken as your score out
of 60. However, if your score exceeds 60, it will be reduced to 60.

2 Questions
2.1 Question 1 [3 points]
In class, we discussed that ∨ and ∧ are associative, i.e., ( A ∨ B) ∨ C is logically equivalent to
A ∨ ( B ∨ C ). Is → an associative logical operation, i.e., is ( A → B) → C logically equivalent to
A → ( B → C )? Hint: Use SageMath.

1
2.2 Question 2 [6 points]
Use the principle of mathematical induction to show that
n
∑ (2i − 1) = n2
i =1

Comment: A visual proof of this identity can be seen here: https://www.youtube.com/watch?


v=MM7fb1HaRYQ

2.3 Question 3 [10 points]


Solve the following recurrence (find an expression for Xn as a function of n):

Xn = 4Xn−1 + 3Xn−2 − 18Xn−3 for n ≥ 3


X0 = 0
X1 = 5
X2 = 31

You must show the procedure you used to arrive at your answer.
Hints:

• You can use SageMath to compute roots of polynomials. For example, the code be-
low computes the roots of p( x ) = 2x2 − 3x − 1. The output is a list of the form
[(r1 , m1 ), (r2 , m2 ), ..., (r j , m j )] where r1 , r2 , ..., r j are distinct roots and m1 , m2 , ..., m j are their
corresponding multiplicities. Multiplicity indicates how many times a root is repeated.

In [8]: #Define a variable called x


var('x')

#Define the polynomial p(x)


p = 2*x^2 - 3*x - 1

#Compute roots of p(x)


p.roots()

Out[8]: [(-1/4*sqrt(17) + 3/4, 1), (1/4*sqrt(17) + 3/4, 1)]

• You can also use SageMath to solve a system of linear equations. The sample code below
solves the following system of linear equations:

x + 2y − z = 2
3x − y − 2z = −5
x+y+z = 6

The output of the code indicates that the solution is x = 1, y = 2, z = 3.

2
In [9]: #Define variables
var('x, y, z')

#Define list of equations


# Note: == is used to specify equality, not =
eqns = [x + 2*y - z == 2, 3*x - y - 2*z == -5, x + y + z == 6]

#Find solution
solve(eqns, x, y, z)

Out[9]: [[x == 1, y == 2, z == 3]]

2.4 Question 4 [10 points]


Let α be a fixed real number. Consider the following recurrence:
Xn = αXn−1 − Xn−2 for n ≥ 2
X0 = 1
X1 = 2

a. [3 points] Plot Xn as a function of n for different values of α. In particular, consider three


cases: (i) α > 2, (ii) α = 2, and (iii) 0 ≤ α < 2. You should include one plot for each case in
your submission.
b. [5 points] What differences do you see in the plots obtained in the three cases mentioned in
part a (these should be qualitative differences)? Provide an explanation for these differences.
c. [2 points] Will the observations that you made in part b depend on initial conditions? For
example, will your answers change if X0 and X1 were 5 and 10 respectively instead of 1 and
2?

Plotting Help: The function below computes the sequence Xn , 0 ≤ n ≤ nmax for specified values
of α and nmax .

In [10]: #Function to compute Xn


# Default value of alpha is 2
# Default value of nmax is 20
def sequence(alpha = 2, nmax = 20):
X = [1, 2]
for i in range(2, nmax + 1):
X.append(alpha*X[i-1] - X[i-2])
return X

The function code needs to be included only once in your document. Each time you wish to
make the plot for a different value of α, use the code shown below. This code calls the sequence()
function to compute Xn and then plots it. In the example, α = 2.5 and nmax = 50. Copy the code
below for every plot you wish to include in your document and change the value of variables
alpha and nmax to desired ones. Depending on the value of α, you may wish to use a linear or a
logarithmic y-axis. This can be specified using the scaletype variable.

3
In [11]: #Desired value of alpha
alpha = 2.5

#Desired value of nmax


nmax = 50

#y-axis scale type (linear or log)


# Change this to scaletype = "linear" for a linear y-axis
scaletype = "semilogy"

#Plot the sequence


list_plot(sequence(alpha, nmax), \
plotjoined = True, \
scale = scaletype, \
axes_labels = ["$n$", "$X_n$"], \
title = "$X_n$ as a function of $n$ for $\\alpha =" + str(alpha) + "$")

Out[11]:

4
2.5 Question 5 [12 points]
The following students have volunteered to participate in a student committee:

Name Batch Major Hostel


Aneesh 1st Year Biology UG1
Bhuvana 2nd Year Biology UG2
Chandrakant 3rd Year Biology UG 2
Devika 1st Year Economics UG1
Edupalli 2nd Year Economics UG1
Fatima 3rd Year Humanities UG2
Gautam 1st Year Humanities UG1
Hansika 2nd Year Humanities UG2
Ismail 3rd Year Physics UG2
Jaya 2nd Year Physics UG2

In order to form the committee, the following constraints have to be satisfied:

• There must be a member from every batch.

• There must be a member from every major.

• There can be at most two members from any major.

• There must be a member from both hostels.

• There should be one physics and one biology student from the same batch. There could be
other students from these majors.

• There should be one humanities and one economics student from the same batch. There
could be other students from these majors.

• The following pairs of students do not get along and at most one student from each pair can
be part of the committee.

– Aneesh and Devika


– Chandrakant and Fatima
– Edupalli and Jaya
– Gautam and Hansika

Based on the information provided, answer the following questions:

a. [6 points] Develop a suitable notation and write propositional formulas corresponding to


the constraints indicated above in SageMath.

b. [1 point] Can Fatima and Hansika both be committee members?

c. [2 points] Is it the case that if both economics students are part of the committee, then all the
remaining members must be residing in UG2?

d. [3 points] If Aneesh has to be a member, is the rest of the committee automatically deter-
mined?

5
Note:

• For part a, no points will be given if you do not clearly state the notation you are using. If
there are mistakes in part a, you will not get any points for the remaining parts.

• Parts b-d should be answered using SageMath.

2.6 Question 6 [12 points]


This is a problem based on counting the number of coin toss sequences.

a. [8 points] Imagine that you keep tossing a coin till you get two consecutive heads. How
many distinct coin toss sequences are there of length n (i.e., a total of n coin tosses)? Clearly,
n must be ≥ 2 and the last two tosses must be HH. Let Sn be the total number of distinct
sequences of length n ≥ 2. These distinct sequences can be partitioned into two mutually
exclusive sets: those in which the first toss is H, and those in which the first toss is T. Let Hn
and Tn be the corresponding numbers of these sequences. It is evident that Sn = Hn + Tn .

• i. [1 point] What are the values of S2 , H2 and T2 ?

• ii. [3 points] Formulate a recurrence for Hn and Tn . In particular, express Hn in terms of


Hn−1 and Tn−1 . Likewise, do the same for Tn .

• iii. [4 points] Solve the recurrence in the previous part and hence find an expression for Sn
as a function of n.

b. [4 points] This part is a variant of part a. Find the number of distinct coin toss sequences of
length n that end in HT, i.e., a heads followed by a tails. You can adopt a similar approach
to part a, but you will find that the recurrence is simpler to solve.

2.7 Question 7 [17 points]


Before proceeding with this problem, you should read about generating functions using this
link:http://discretetext.oscarlevin.com/dmoi/section-27.html.

a. [5 points] Recall that the nth Fibonacci number, f n , is defined using the following recurrence:

f n = f n −1 + f n −2
f0 = 0
f1 = 1
Let F ( x ) be the generating function for f n , i.e., let F ( x ) = ∑i∞=0 f i xi . Show that
x
F(x) =
1 − x − x2
b. [7 points] Show that

6
" √ !n √ !n #
(n) n! 1+ 5 1− 5
F (0) = √ −
5 2 2

Here, F (n) (0) is the nth derivative of F ( x ) evaluated at x = 0. Hint: Compare the Taylor
series of F ( x ) about x = 0 with the generating series.

c. [5 points] Show that the generating function for the sequence sn = n is given by

x
S( x ) = ∑ s i x i = (1 − x )2
i =0

Vous aimerez peut-être aussi