2014年12月1日星期一

Problem-solving Eposide - Diagonals


Understanding & Plan

According to the given example, I found out that when m = 4 and n = 6, the diagonals of the rectangles will cross 2*m = 8 little squares (means for each row it will cross exactly 2 little squares). Then we just need more cases and find out the pattern of m, n and number of squares the diagonal cross. For better understanding, we can draw the graph from n = m = 1 and come up with a table:




Then I found that there's a pattern when m = n, # of squares = m = n; when m > n, #of squares = n+1 if n is odd, = n if n is odd; when m<n,  # of squares = m+n - 1 if n, m is even, # of squares = m+n - 2 if m,n is even

so we have the function:
def get_number_of_squares(m,n):
      """
      (int, int) -> int
      """
      
      if m == n:
             return m
      if m>n and n%2 == 0:
             return 2m+1
      elif m>n and n%2 != 0:
             return 2m
      
      if m<n and m%2 == 0 and n%2 == 0:
             return m+n -2
      elif m<n and m % 2 == 0 and not n % 2 == 0:
             return m+n-1
      elif m<n and not m%2 == 0 and n%2 == 0:
             return m+n-1
      elif m<n and not m%2 == 0 and not n%2 == 0:
             return m+n-1

2014年11月30日星期日

Slog for week Nov. 24

What's new?

This week we are going further on stuff about computability theory from last week. First of all, the idea that every listable set is countable make me clearly understand what is a countable set. To make sure a set is countable, we can just make a list of input and a list of corresponding output, then if there're no identical output and input, then the set is countable (since it satisfied both onto and 1-1 at the same time).

Then, we've talked about induction. Induction is quite understandable for me since I'm taking MAT 137 right now and the approach is normally using in mathematical proof.



Questions & concern:

1. On the lecture, I'm quite confused that what is UTF-8?

2. I'm quite confused about countable and computable. Under my understanding, countable is related to sets, however computable is related to functions. Is it correct? Is there other way to distinguish these two words in logic?

3. I'm quite confused about Friday's lecture. Are there any questions on final exam related to the knowledge on Friday's lecture?

2014年11月23日星期日

slog for week of Nov. 17


  • What's new?

          This week's a short week, but stuff for this week is totally new and super difficult for me I think. And honestly, I'm very confused about what we've learnt in this week. A totally new concept - computable and non-computable, had been introduced to us, through the example function, halt. 

          Then we've learnt about finite sets. This part is more understandable i think, especially the concept of 1-1 and onto cause they've been introduced in other math courses like MAT223 and MAT137(something related to other courses). Thus I can understand whynot 1-1 will result over-count and not onto result undercount. And we have the conclusion: every set which is smaller than natural number set is always countable. 

  • Problem?

          1. I'm not quite well understand the halt function and navel_gaze function which were talked about on Wednesday's lecture. What makes them become non-computable function? And how I can distinguish a given function is computable or not?

          2. Friday's lecture, our prof said set of rational number has the same size to the set of  natural number. I'm questioning why? 

          

2014年11月15日星期六

Slog for Week Nov. 10


  • What we've learnt for this week?

          This week we've learnt how to prove and disprove a given function is in big-Oh and big-omega. After this week's lecture, through reading the given proof example by our instructor, I found that I clearly understand the meaning of break-even point(B) and my confuse from last two week, about how to choose B, has been solved.

          Another new concept from this week is about F (general statement about two functions). This part is very challenged for me indeed, but through instructor's note, I think I'm kind of understanding how to prove (but obviously I'm still not proficient on proving this kind of questions, thus I still need more practices).


  • Confuse and challenge:

  1. As I was proving Big-O, I carefully write down the statement we want to prove. Then, I realize when two functions is coinciding as variable'n'  become infinitely big, then one of the function is still in Big-O of the other function. So why? Obviously the second function is not larger than the first function anymore. 
  2. One of the example question is using  limit and l'Hôpital's rule. So I'm confusing are we allow to write some scratch work about limit and l'Hôpital's rule first, then start our actual proof below it?  

2014年11月10日星期一

Slog for Week Oct. 27

We’re going further on the topic of sorting method and big O/omega. But as we’re moving on, I’m getting more and more confused about this chapter’s topic.
  1. While we are counting the running steps of a program, if a statement is false (like while loop, while n<100, and now n = 101), is it still counting as 1 step?
  2.  I’m not quite understanding the big O, particularly the Breakpoint B. As we are making a proof of big O, what kind of number we should take for B? (as specific as possible)3.       When I’m counting steps, I usually struggle on this kind of problem:
  3.     .     When I’m counting steps, I usually struggle on this kind of problem:




so as we’re counting running steps of a while loop inside a while loop, is it the easiest way to start from the inside while loop?

Slog for Week Nov. 3

  • What's new? & Problem

      This week’s lecture is more understandable than last week I think. That is because we start focusing proving the Big O/omega, instead of counting steps and working with a series of number. It seems easy because we just need to remember the statement of Big O and following the structure of proof we’ve learnt before. But there’s still an easy question: why B and C have to be nature number instead of any positive real number? 

Slog for Week Oct.20

  • What's new and some problems:


    On this week’s lecture we’ve ended the chapter of Proof by introducing some inferences. These inferences briefly and clearly show us how to prove in some situations and what should do next if we’ve already assume everything.  Additionally, some sorting methods, such as insertion sort and selection sort have been mention in the lecture. Because I haven’t learnt these sorting methods before, I’m feeling very confused about which method is the best and which one takes the least steps if I have a very large input. Besides, I’m still confusing about when I should use linear search and when should use insertion sort/selection sort. 

2014年10月17日星期五

Slog for week started from Oct. 13

What’s new?
  • 1.       This week, we are introduced to a new math expression-floor, shown by │_x_│. This part is quite new for me and I think it has very similar idea to what is called limit in our MAT137 class (but I consider that they are not equal). I think using floor is very convenient us to calculate.
  • 2.       We are discussing how to prove a statement is false. 





Questions

  • 1.       But I’m quite confused about that why │_x_│+1>│_x_│ is equivalent to │_x_│+1>x? Can I say that the difference between │_x_│ and x is at most very close to 1 but at least 0?
  • 2.       To simplify the idea, is this part meaning that our goal to finding a contra-example for the given statement so that we can prove it true?


2014年10月3日星期五

Slog for week Sept. 29


  •  What’s new for this week?


This week we are introducing to some properties of implication (transitivity). Then, we are discussing infinity, I realize that this part is very related to what we are learning on mat137 right now-the proof of limit. Last but not least, the Proof Outline part is new to me so that I'm feeling interested in it. And I'm wondering are we required to write our proof with the exactly same format to this proof outline?


  •  Challenge


When i'm working on my assignment 1, a question confused me. For two statement, (there exist a in A, C(a) and B(a)); (there exist a in A, not B(a) and not C(a)),  I know these two statements are contrapositive, but are they equivalent? 

2014年9月26日星期五

Slog for Week Sept. 21

  •  What’s new for this week?


This week we are going further with the topic negation and the application of conjunction and disjunction (‘and’ and ‘or’). Besides, other concepts about tautology, satifability and unsatisfiability are introduced in our class.


  •  Challenge



As I’m reading the commutative, associative and distributive approach of logic (PPT the last second slide), I’m wondering is statement (Q V┎ Q) a true statement or not? Besides, I’m still confusing why the statement P ∧ (Q ∨ ┐Q) is equivalent to P? It means P, and  Q or not Q. If (Q V┎ Q) is a true statement, then I think P ∧ (Q ∨ ┐Q) should be interpreted as P and Q or P and not Q. Why isn’t it?

2014年9月18日星期四

Slog for Week Sept. 14

-What’s something new I learned this week?

    This week we learned some concepts about existential claims, contrapositive and converse of statements, but mainly focus on implication of statements. Through this week’s classes, I was trained to easily understand a given statement and its implication as well.

-Challenge

In Wednesday’s class, we were going further on the topic of implication, converse and contrapositive. I'm still confused about the question on the slide, under the subtitle Numerical Example:


For the first given situation, if n is a multiple of 4, why the converse doesn't give us any information? The first sentence of this question has already defined P(n) is n and Q(n) is n^2. So, for the converse, we start at the Q(n) first, if n is multiple of 4 (such that 4t for t is a subset of N), then we can know Q(n) must be a multiple of 4 because Q(n) = n^2 = (4t)^2 = 16t^2, which indicates that Q(n) is true and P(n) is true as well. However, in the class professor Heap told us to consider the case of 2, but I think this case is impossible for this situation because if n = 2, then it is not a multiple of 4, which is contradicting with the given condition and seems illogical. These are all the reasons why I stuck on this question for a long time.


-Tutorial

    The tutorial exercise for this week is mainly focus on implication. It is not very challenging for me, but I think we had wasted lots of time on discussing some very silly questions during the tutorial time. However, the exercise gives me an opportunity to practice the knowledge I learned from class and I think it is very necessary. I also found that drawing a Vane Graph is a efficient way to understand the implication of a statement.