Sunday, October 28, 2012
Drawing Function vs Fitting Model in R
layout(matrix(c(1,2), 1,2, byrow=TRUE))
# http://www.stat.umn.edu/geyer/5102/examp/reg.html
qftn <- function(x) x^2 * 3
curve(qftn, 1, 3, main = "Function: y = x^2 * 3")
x <- c(1:3)
y <- c(3, 12, 27)
plot(x, y, main="Fitting model: y = x^2 * 3")
model <- lm(y ~ I(x^2 * 3))
curve(predict(model, newdata = data.frame(x = x)), add = TRUE)
# May also draw the coordinate pairs, like so:
text(1,4, "(1,3)")
text(2,13, "(2,12)")
text(2.9,27, "(3,27)")
Wednesday, October 24, 2012
Goldbach Conjecture and odd numbers > 5
Prove that if every even natural number greater than 2 is a sum of two primes (the Goldbach Conjecture), then every odd natural number greater than 5 is a sum of three primes.
== Solution ==
This is equivalent to asking if every even natural number greater than 2 is a sum of two primes,
|
∀(n∈N∧n>1)∃(p,q∈P)[p+q=2n]
|
is it true that:
|
∀(m∈N∧m>2)∃(r,s,t∈P)[r+s+t=2m+1]
|
Exploiting m > 2 and n > 1:
|
∀(m∈N∧m>2)∃(x∈N)[x=m−1>1]m=x+1>2
|
Now,
But x is greater than 1 which means 2x is an even number greater than 2, and therefore is a sum of two primes. Since 3 is prime, (2m + 1), an arbitrary odd natural number greater than 5, is therefore a sum of three primes.
Tuesday, October 23, 2012
Composite f(n)=n2+bn+c
Prove that there is a quadratic f(n)=n2+bn+c, with positive integers coefficients b, c, such that f(n) is composite (i.e, not prime) for all positive integers n, or else prove that the statement is false.
== Attempt ==
|
f(n)=n2+bn+c=(n2+b2)2−b24+c
|
This means when
Then,
which is composite !
12|n and 12|n3
Prove or disprove the statement “An integer n is divisible by 12 if and only if n3 is divisible by 12.”
== Solution ==
If integer n is divisible by 12, for some integer m:
Clearly,
n3 is divisible by 12. How about the converse ? Is n divisible by 12 if
n3 is divisible by 12 ? Note
12=22×3, so one counter example would be:
In other words,
n3 is divisible by 12, but not n. Hence the converse is false.
Monday, October 22, 2012
Prove √3 is irrational
Prove that √3 is irrational.
== Attempt ==
First, let's prove the lemma that if the square of an integer n is divisible by 3, n must be divisible by 3. Why ? A integer can be written in only one of 3 forms:
|
Case 1:n=3xCase 2:n=3x+1Case 3:n=3x+2
|
where x is an integer. If we take the square of n in each case:
|
Case 1:n2=(3x)2=9x2Case 2:n2=(3x+1)2=9x2+6x+1=3(3x2+2x)+1Case 3:n2=(3x+2)2=9x2+12x+4=3(3x2+4x+1)+1
|
Note that only in case 1 when n is divisible by 3 would
n2 be divisible by 3. This completes the proof of the lemma.
Now suppose √3 is rational,
such that p and q has no common factors. Squaring both sides,
This means
p2 is divisible by 3. By the above lemma, this means p must be divisible by 3. Or p = 3r for some integer r.
This means
q2 is divisible by 3, and by the lemma above, q must be divisible by 3. To summarize, both p and q are divisible by 3, but this contradicts the initial assumption that p and q has no common factor!
Hence √3 is irrational.
Sunday, October 21, 2012
Proof of perfect square
Prove or disprove the claim that for any positive integer m there is a positive integer n such that mn + 1 is a perfect square.
== Attempt ==
First, the claim can be expressed as:
Observe that:
|
m⋅n+1=r2m⋅n=r2−1m⋅n=(r+1)(r−1)n=(r+1)(r−1)m
|
This means if the claim is true, m must divide either (r + 1) or (r - 1):
|
∃(x∈N)[(m⋅x=r+1)∨(m⋅x=r−1)]
|
Or,
|
∃(x∈N)[(r=m⋅x−1)∨(r=m⋅x+1)]
|
For example, when m = 1, the smallest value of r such that n > 0 would be when x = 3. So:
|
r=1⋅3−1=2n=(2+1)(2−1)1=3m⋅n+1=1⋅3+1=22
|
Given m >= 1, we can always pick a value x such that:
This is when:
which means we can always find a value r (from m and x) and n (from r and m) that satisfies the claim. This completes the proof.
Thursday, October 18, 2012
What's the laziest possible thing a programmer can do ?
Ask the above question ! Or, in short, recursion :)
