Proving a recurrence relation by induction [closed] - math

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have a test coming up, and I need some help with a practise question... Need to prove this by induction:
Reccurence relation: m(i) = m(i-1) + m(i - 3) + 1, i >= 3
Initial conditions: m(0) = 1, m(1) = 2, m(2) = 3
Prove m(i) >= 2^(i/3)
Here is what I have been able to do so far:
Base case: m(3) >= 2 -----> 5 >= 2. Therefore it holds for the base case.
Induction Hypothesis Assume there is a k such that m(k) >= 2^(k/3) holds.
Now I must prove that it holds for k+1.
So we have: m(k+1) >= 2^((k+1)/3)
which equals (by substituting hypothesis):
m(k) + m(k-2) + 1 >= 2^((k+1)/3)
This is where I am stuck. I'm not sure where to go from here. Any help will be appreciated. Thanks guys!

Hints:
Prove that m(k) >= m(k-2). (This is trivial.)
Since m(k+1) = m(k) + m(k-2) + 1, you can replace = with >= to get m(k+1) >= m(k) + m(k-2) + 1.
You can make substitutions on the right-hand side of >=, as long as what you put in is less than or equal to what you take out. Start by using #1 to make a substitution in #2.

Consider your base case: you show that for 3 prior consecutive given values for m(0), m(1), and m(2), that the formula holds for m(4). Then show that m(k+1) formula works if you assume that it's true for 3 prior values m(k), m(k-1), and m(k-2) [this is valid for induction].
By initial condition
m(k+1) = m(k) + m(k-2) + 1
Substitution:
m(k+1) >= 2^(k/3) + 2^((k-2)/3) + 1
Factor the right hand side in terms of 2^((k+1)/3) [HINT: leave the +1 alone] and it should fall out from there.

Related

How many ways to get a sum of consecutive whole numbers that total x? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
How would one go to programmatically tackle these questions:
How many different ways are there to write:
a) 2021 as the sum of consecutive whole numbers?
b) x as the sum of consecutive whole numbers?
Supposing the order of the numbers isn't important, there are 8518741657943308344041302580996941768179250799 ways to write 2021 as a sum of positive integers. It's called the partition number. There isn't a simple formula, but there is a recurrence relation that allows to calculate a lot of values.
The function is implemented in Python's sympy:
from sympy import partition
print(partition(2021))
Now, for the new question, to write 2021 as the sum of consecutive integers: n + n+1 + ... + m-1 + m = 2021. First note that negative values for n don't add anything interesting. When n < -m, the sum would clearly be negative. Otherwise, the negative values just "eat up" the corresponding positive values, and you get the same sum as a positive solution.
The sum of the numbers from 1 to m is tri(m)=m*(m+1)/2, (the triangular number). The sum of the numbers from n to m is just tri(m)-tri(n-1). These equations can be solved by a SAT/SMT solver such as Z3:
from z3 import Int, Solver, And, Or, sat
s = Solver()
m = Int('m')
n = Int('n')
s.add(And(n > 0, n < 2022))
s.add(n <= m)
s.add(And(m > 0, m < 2022))
s.add(m * (m + 1) - n * (n - 1) == 2021 * 2)
while s.check() == sat:
mi = s.model()[m].as_long()
ni = s.model()[n].as_long()
if ni > mi - 30:
print("+".join([str(i) for i in range(ni, mi + 1)]), end="=")
else:
print("+".join([str(i) for i in range(ni, ni + 6)]), "+...+",
"+".join([str(i) for i in range(mi - 4, mi + 1)]), end="=", sep="")
print(sum([i for i in range(ni, mi + 1)]))
s.add(Or(m != mi, n != ni))
Output:
26+27+28+29+30+...+64+65+66+67+68=2021
20+21+22+23+24+...+62+63+64+65+66=2021
1010+1011=2021
2021=2021
So, for 2021 there are 4 positive solutions (and 4 corresponding solutions that would include the negative numbers from 1-n to m).

Formula to find square root of a natural number using only addition and subtraction [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
How to use only addition and subtraction to find out square root of a natural number?
Thanks.
[I have looked over the internet but i didn't find any content related to this problem.]
Explanation to my problem: I want to create a c function which will receive only a natural number and return square root of it.
You may say to use the "sqrt" function but i just thought of creating one which will utilize addition and subtraction operator to create the square root.
You don't have to write the program, just writing the formula for it will be just fine. Thanks.
Update: This question is not specifically about coding rather about mathematics.(I tagged "c" as it had some link but this question is NOT about coding.)
n2 is the equivalent of the sum of the n first odd numbers.
You can iterate over the n (consequently adding only the next odd number to the previously calculated sum) until the square is equal or exceeds your number.
k = 0
sum = 0
while sum < target:
k += 1
sum += 2k-1
if sum > target:
the target doesn't have integer root
else:
k is the square root
We can use the fact that (n+1)² = n² + 2n + 1.
def sqrt(n):
k = 0
s = 0
while s <= n:
s = s+k+k+1
k = k+1
return k-1
print (sqrt(0)) # 0^2
print (sqrt(1)) # 1^2
print (sqrt(2)) # (1.4142135623730951...)^2
print (sqrt(144)) # 12^2
print (sqrt(169)) # 13^2
print (sqrt(196)) # 14^2
print (sqrt(255)) # 15^2
print (sqrt(1000)) # (31.622776601683793...)^2
print (sqrt(2000)) # (44.721359549995796...)^2
UPD
Sorry, I thought you were asking for code :)

How does using log10 correctly calculate the length of a integer? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
int length = (int) floor( log10 (float) number ) + 1;
My question is essentially a math question: WHY does taking the log10() of a number, flooring that number, adding 1, and then casting it into an int correctly calculate the length of number?
I really want to know the deep mathematical explanation please!
For an integer number that has n digits, it's value is between 10^(n - 1)(included) and 10^n, and so log10(number) is between n - 1(included) and n. Then the function floor cuts down the fractional part, leaves the result as n - 1. Finally, adding 1 to it gives the number of digits.
Consider that a four-digit number x is somewhere between 1000 <= x < 10000. Taking the log base 10 of all three components gives 3.000 <= log(x, 10) < 4.000. Taking the floor (or int) of each component and adding one gives 4 <= int(log(x, 10))+1 <= 4.
Ignoring round-off error, this gives you the number of digits in x.

Expand 2^(k + 1) [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
http://doyourmath.com/web-algebrator/#c=expand_algexpand&v5=2%5E(k%2B1)
Anyone can explain why does expand 2^(k + 1) equal to (2^k) + 1?
That's not actually possible. 2^(k+1) is always going to be an even number. 2^k + 1 is always going to be an odd number.
I think you mean
2^(k+1) = 2^k * 2^1 = 2^k * 2.
One way of looking at it is the associative property of multiplication:
(2 X 3) X 4 = 2 X (3 X 4)
No matter how you group the numbers, the outcome will always be equal. In this case we're dealing with exponents, which is a shorthand notation for multiplying a number by itself.
It is not!!!
2^(k+1) = 2^k * 2 which is greater than 2^k + 1
Instead (k+1)^2 expands to (k^2)+2k+1
http://doyourmath.com/web-algebrator/#c=expand_algexpand&v5=2%5E(k%2B1) has ERRORS!

Basic Query Concerning Discrete Math [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
My professor gave an example located on slide 3 of this pdf: can anybody explain to me how he ended up with m_n = 2^(n) - 1. Thanks!
The step is from
mn =2n−1 +2n−2 +...+22 +2+1.
to
mn = 2n − 1
There are two ways to make the step. One is to recognize this as a geometric series, and know the rule:
sum=(1-rn)/(1-r)
The other is to have played around enough with powers of two to know that if you add up a bunch of them starting from 1, you get the next one, minus one.
There is a formula for the sum of the first n terms of a geometric series.
1 + 2 + 2^2 + 2^3 + ... + 2^{n-1}
= (1 - 2^n) / (1 - 2)
= (1 - 2^n) / (-1)
= 1/(-1) - 2^n/(-1)
= 2^n - 1
It's just one of the relations of series that people have figured out over the years:
2^(n-1) + 2^(n-2) + ... + 2 + 1 == 2^n - 1
You can think of it a lot like the sum of binary numbers:
000001
000010
000100
001000
+ 010000
------
011111 == 1000000 - 1
Actually,
Mn=2^0+2^1+.........+2^(n-1)+2^(n-2)
is the Nth term of the sequence Mk=.....
And this Nth term itself is a sum of a geometrical progression whose 1st term is 1(2^0) and common ratio=2.
And this sum(Mn) is
=a[(r^n)-1]/[r-1]
where a is 1st term and r common ratio
=1*[(2^n)-1]/[2-1]
Mn=2^n - 1

Resources