Monday, December 1, 2014

CSC165 Comments

Comments

It has been a really good experience to be in this course. My professor and TA have done a pretty good work on explaining the concepts of the course. Moreover, I really learned a lot about proofs, which helped me to increase my logical skills. Being in this course also helped me to wrap my head around the topics in MAT137. As I have shown on my blogs, the relationship between MAT137 and CSC165 is strong and allows us to understand the concept of proving better. This week, Professor Heap mentioned that we should include the links of the Blogs in which we have commented on, so I would like to include some of them here.












Friday, November 28, 2014

CSC 165 Computability, review

Week #12
Topic: computability, review

I really enjoyed learning about induction in a more sophisticated way. I always thought of induction as a process of going from a known case called base case to making generalizations that involve n and n+1 cases. The approach taken in class to prove statements by using the induction method made me fully understand how this method works.
I tried some somehow complex examples involving induction to reaffirm my knowledge.

Prove for all positive integers n, that 4n + 15n -1 is divisible by 9.

The first thing to notice in this exercise is that we are talking about positive integers which suggests that you should use induction to prove this statement.
As suggested in class, let’s start with the inductive step

Inductive Step
Assume 4n + 15n -1 is divisible by 9 # Induction hypothesis
We want show 4n + 1 + 15(n + 1) -1 is divisible by 9
4n + 1 + 15(n + 1) -1 = 4n + 1 + 15n + 15 -1
                                = 4n + 1 + 15n + 14
                                = (4n + 1 + 60n - 4) - 45n + 18           
                               # Manipulating the expression to use our induction hypothesis
                               ≡ 0 – 45n + 18 (mod 9)           # By induction hypothesis
                               ≡ 0 – 0 + 0         # 45n (mod 9) = 0 and 18 (mod 9) = 0

Since we did not notice any restriction on n, we can continue our induction process by establishing our base case.

Base Case
n = 1
4n + 15n -1 = 4(1) + 15(1) -1 = 18 ≡ 0(mod 9)


Another interesting induction problem is the following

Recall that {Fn}, the Fibonacci sequence, is defined by F1 = 1, F2 =1, and Fn = Fn – 1 + F n – 2 . Let r be a positive constant that satisfies the property that r2 = r + 1. Prove that  rn = Fn r + Fn – 1 .

Inductive Step
Assume rn = Fn r + Fn – 1 .     # Induction hypothesis
We want show rn + 1 = Fn + 1 r + Fn
rn + 1 = rn * r = (Fn r + Fn – 1) r         # By Induction hypothesis
          = (Fn r + Fn +1 - Fn ) r # Fn – 1  = Fn +1 - Fn
               = Fn r2 + Fn +1 r - Fn r
          = Fn +1 r + (Fn r2 - Fn r)
          = Fn +1 r + (Fn (r2 - r))
          = Fn +1 r + Fn      # r2 = r + 1

Here we notice that for the Fibonacci formula to work we need at least two elements. Therefore, we structure our base case as follows:

Base Case
n = 2
r2 = F2 r + F1
r2 = r + 1

Overall, it was a very good experience to do these SLOGS. Moreover, these posts helped me to reaffirm my knowledge and to increase my confidence when dealing with the material learned. Also, I really enjoyed learning all the topics taught in CSC165 and I hope that I will find more opportunities to apply math in Computer Science in upper years.


Friday, November 21, 2014

CSC 165 Halting problem, computability

Week #11
Topic: halting problem, computability

This week’s material was more difficult than the material given in other weeks. For this reason, I would like to take advantage of this space to enhance the knowledge received.

Halting Problems

One of the most interesting and somewhat abstract concept was the one dealing with halting problems. I managed to wrap my head around this idea by thinking about it in the following way:

Consider these functions:

def H(f, i):
            ¨ ¨ ¨ Return True if f(i) will halt, False otherwise. ¨ ¨ ¨
return True

def navel_gaze(f):
            while H(f, f):
                        pass
            return 42
Now, let's relate these functions to each other.

H is a function that takes two arguments. Taking f and f as arguments means that we are running the program f on a program f. We do not really have to understand what happens when running   f(f). All we care about is whether that halts or not.

H(f, i) as well H(f, f) return True if they halt and False if they do not halt.

Now, a very important question is: What does the above mean in terms of the specific statement while H(f, f):?
While is an expression that is going to keep running until the statement within it becomes False. H(f, f) is false if f does not halt. However, if it does not halt then f halts because we just get out of the loop and return 42.
By using the same argument, we can see that  H(f, f) is true if f halts. However, if it halts then we stay in the loop and the program does not halt.

This is a contradiction because the program halts if, and only if, it does not halt. And, the program does not halt if, and only if, it halts.

One to one functions

When dealing with one to one functions we can always use its definition, as suggested in class. However, if we happen to have a graph of the function we are working with, drawing horizontal lines is an easier way to determine whether a function is one to one or not. This intuitive idea of checking whether we have a different f(x) for each x in the domain is what makes us come up with the formal definition.

f : A B is 1-1: x, y A, f(x) = f(y) x = y
This definition says that my enemy picks any x, y, and if we get the same result by plugging two numbers, that must be because we plugged in the same number. In other words, the result is the same because x refers to the same number that y refers to.


After understanding these key concepts, I feel more comfortable with the material learned.

Friday, November 14, 2014

CSC 165: big-Omega, big-Theta, general properties

Week #10
Topic: big-Omega, big-Theta, general properties

I had mentioned before that this course has some similarities with MAT137. When analyzing this week’s material I realized that the connection between these two courses is really strong. For instance, the new bound that combines both big-Omega and big-Theta looks very similar to the mathematical concept of Pinching theorem. Also, the way in which we proved the general statements about two functions is quite similar to proving limit laws. In the following part I will try to show how related CSC165 AND MAT137 are.

CSC 165
·         f  O1 (g)
{f: ≥0 | c1 +, c2 +, B , n , n ≥ B c1 g(n) ≤ f (n) ≤ c2 g(n)}
Application
Let’s apply this concept to – (n2) < 0 < n2 in which case n is any typical natural number, c1 = 1, c2 = -1, and B ≥ 0



 











MAT 137
·         Pinching Theorem
Let f, g, h be functions
If p > 0 such that 0 < |n –a | < p and
 g(n) ≤ f (n) ≤ h(n) and the limit of both g(n) and h(n) are the same as n approaches a.
Then, the limit of f(n) as n approaches a is the same as the ones above
Application
x < x sin(1/x) < -x

 


Connection: If we look at the graph that deals with the pinching theorem we notice that x when B ≥ 0, x sin(1/x) is between x and –x or what is the same, between c1x and c2x, in which case c1 is 1 and c2 is -1. Exactly as happens with the new bound learned this week.


PROOFS


CSC165                                             
Prove F = {f: ≥0} f, g, h  F,
(f O(h) g O(h)) f + g O(h)
Assume f, g, h  F # Introduce
Assume (f O(h) g O(h)) #Antecedent
Then cf +, Bf , n , n ≥ Bf f(n) ≤ cf * (h(n))
Then cg +, Bg , n , n ≥ Bg g(n) ≤ cg * (h(n))
Prove c +, B , n , n ≥ B f(n) + g(n) ≤ c * (h(n))
Pick c = cf + cg. Then c +
Pick B = max (Bf, Bg). Then B
Assume n , n ≥ B
Then (f + g) (n) = f(n) + g(n) ≤ cf * (h(n)) + cg * (h(n)) 
#By assumption n≥ B, n ≥ Band n ≥ Bg
                                                            ≤ (cf + cg) * (h(n))
                                                            = c * (h(n)) # c =  cf + cg
Conclude f, g, h  F, (f O(h) g O(h)) f + g O(h)

MAT 137
Prove If the limit of f(x) as x approaches a is equals L and the limit of g(x) as x approaches a is equals M. Then the limit of f(x) + g(x) as x approaches a is equal to L + M

Asume  = L and the limit of f(x) as x approaches a is equals L and the limit of g(x) as x approaches a is equals M.
Then e , d , x , |x – a | < d |(f(x)) - L| < e1 = e/2
Then e , d , x , |x – a | < d |(g (x)) - M| < e2 = e/2
Prove e , d , x , |x – a | < d |(f(x) + g(x)) – (L + M)| < e
Assume e
Take d= min(d1, d2)
Assume x |x – a | < d
Then  |(f(x) + g(x)) – (L + M)| = |(f(x) - L) + (g(x) - M)| ≤ |(f(x) - L)| + |(g(x) - M)|
= e/2 + e/2 = e
Conclude e , d , x , |x – a | < d |(f(x) + g(x)) – (L + M)| < e

Connection

In both cases, we assumed two things and used our assumptions to prove the final result. Even though these two proofs prove something completely different, they follow the same principle and use the same tools