Solve Recurrence Equation w/2 Base Cases Same Result

In summary, the conversation discusses a recurrence equation and how to find a closed form for it. The equation is unrolled and a closed form is found, but there is an issue with the base case. The solution is to use a piecewise function.
  • #1
ATroelstein
15
0
This question is related to the question that I have asked here, although the equation is ever so slightly different:
http://www.mathhelpboards.com/f15/solving-specific-variable-when-solving-recurrence-equation-3804/

I have a recurrence equation of the form
$$
T(n) = 0, n = 0, n = 1\\ T(n) = T(\frac{(n-1)}{2}) + 2, n > 1
$$

By unrolling the equation, I get (thanks to I like Serena's help :)):

$$
T(n) = T\left(\frac{n-2^k+1}{2^k}\right) + 2k
$$

Now if I solve for k when
$$
\frac{n-2^k+1}{2^k} = 0
$$

I get
$$
k = log(n+1) - 1
$$

Substituting this back in
$$
T(n) = T(1) + 2*(log(n+1) - 1)\\
T(n) = 2*(log(n+1) - 1)
$$

Now if I wanted to prove my closed form is correct, I have to use induction. I can prove the base case of T(n) = 0 when n = 1. The problem results when I want to also show that the other base case of T(n) = 0 when n = 0. I ran through the full inductive proof and was able to show my closed form is correct, except that lingering base case of 0. How would I go about solving the equation so that I also take into consideration that base case as well? Thanks.
 
Physics news on Phys.org
  • #2
Hi ATroelstein! :)

When we fill in n=1 in your recurrence relation $T(n) = T(\frac{n-1}{2}) + 2$, we get:
$$T(1) = T(\frac{1-1}{2}) + 2 = T(0)+2=0+2 \ne 0$$
So your boundary conditions for $n=0$ and $n=1$ cannot both be consistent with the recurrence relation for $n \ge 2$.
In other words, there is no solution with just one simple formula.

The solution you would be looking for, is for instance:
$$
T(n) = \left\{\begin{array}{ll}
0 \quad &\text{ if } n=0 \\
2(\log_2(n+1) - 1) \quad &\text{ if } n \ge 1 \\
\end{array}\right.
$$
 

FAQ: Solve Recurrence Equation w/2 Base Cases Same Result

What is a recurrence equation?

A recurrence equation is a mathematical expression that describes a sequence of numbers by relating each term to one or more of the previous terms.

What is a base case in a recurrence equation?

A base case is the starting point of a recurrence equation, where the value of the first term or terms in the sequence is explicitly defined.

Why is it important to have 2 base cases in a recurrence equation with the same result?

Having 2 base cases with the same result ensures that the recurrence equation is well-defined and can accurately describe the sequence. It also allows for a more accurate solution to be obtained.

How do I solve a recurrence equation with 2 base cases and the same result?

To solve a recurrence equation with 2 base cases and the same result, you can use the method of iteration or substitution. This involves plugging in values for the base cases and then using the recurrence relation to find the values of the subsequent terms in the sequence.

What are some real-world applications of solving recurrence equations?

Recurrence equations can be used to model various real-world phenomena such as population growth, compound interest, and the spread of diseases. They are also commonly used in computer science and programming to analyze the time complexity of algorithms and data structures.

Similar threads

Back
Top