Computational Thinking in Undergraduate Discrete Mathematics using Python and Jupyter Notebooks
Talk given in the MAA Contributed Paper Session on Discrete Mathematics in the Undergraduate Curriculum -- Ideas and Innovations, AMS/MAA Joint Meetings, January 2017. Companion website at http://bit.ly/ctdiscrete.
, ... Conjecture: For all , a set with elements has subsets. WHY? (Induction) The empty set has 1 subset. If a -element set has subsets for some , then a -element set has subsets with and subsets without . Hence there are subsets with elements.
Computer Science 1 Sequences and Induction Programming Problem 1: Linear homogeneous recurrence relation solver Goal of this problem In this miniproject, you will write a function in Python called rrsolver that does the following: The function rrsolver accepts four numbers, which are the coefficients and initial conditions of a linear second-order homogeneous recurrence relation written in the form and the input would look like rrsolver(c1, c2, A, B). For example, if the recurrence relation were then the input would be rrsolver(1, 6, 3, 6). In other words there are four inputs, in this order: The coefficient on , the coefficient on , the value of , and the value of . We assume that the recurrence relation has been written as above, with on the left side and everything else on the right side. We are also assuming for this problem that we are only dealing with second-order equations, not third-order or higher. As you know from class work, linear homogeneous recurrence relations can be solved using the characteristic root method. What the rrsolver does with its input depends on how many real-number characteristic roots the recurrence relation has: http://bit.ly/ctdiscrete
a recurrence relation, its initial conditions, and prints out an exponential equation that results in the same sequence. Find the roots of and check to see if is negative. If so, print that there are no real roots. Otherwise construct the roots. The resulting linear system (after plugging in the initial conditions) would look like: Then use numpy to solve the system using a matrix. if the roots are the same, we end up with a slightly different system: In [1]: from math import sqrt import numpy def rrsolver(C1, C2, initial1, initial2): #Based on r^2 - c1r - c2 = 0 #Check if the sqrt ends up being negative. if (((-C1)*(-C1)) - (4*(-C2))) < 0: print('There are no real roots.') else: radican = sqrt(((-C1)*(-C1)) - (4*(-C2))) root1 = ((C1 + radican)/(2)) http://bit.ly/ctdiscrete