Finding an Exact Solution for the Recurrence Formula f(n) = 2f(sqrt(n)) + n

  • MHB
  • Thread starter alyafey22
  • Start date
In summary, the conversation discusses a recurrence formula and its possible solutions. The speaker was able to find a bound for the function, but not an exact solution. They suggest using structural induction and a change of variables to find a possible solution. However, they are unable to find an exact expression for it and doubt that a simple expression exists. Another speaker suggests using the Master Theorem, but there is a disagreement about whether one of the conditions holds. The conversation ends with one speaker providing a possible solution using a substitution and the Master Theorem, but there is a mistake in their calculation.
  • #1
alyafey22
Gold Member
MHB
1,561
1
Hello MHB

Solve the following recurrence formula

$$f(n) = 2f(\sqrt{n}) + n$$

I was able to find a bound for the function but no success in finding an exact solution. Any ideas ?
 
Physics news on Phys.org
  • #2
I don't think there is an easy expression for it. Using structural induction you can easily prove that the following holds for all $k \in \mathbb{N}$:
$$f(n) = 2^k f \left ( n^{2^{-k}} \right ) + \sum_{i = 0}^{k - 1} 2^i n^{2^{-i}} \tag{$\star$}$$
Now if we assume that $f(n) = c$ for all $n \leq 2$ (otherwise the recurrence does not converge) we can plug in $k = \lceil \log_2{\log_2{n}} \rceil$ to get:
$$f(n) = c 2^{\lceil \log_2{\log_2{n}} \rceil} + \sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} 2^i n^{2^{-i}} = c' \log_2{n} + \sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} 2^i n^{2^{-i}}$$
For $n > 2$ and with $c \leq c' < 2c$ depending on how close $\log_2 \log_2 n$ is to its ceiling. Unfortunately the sum does not seem to have a simple exact expression. However it is quite easy to see that the $2^i$ factor is upper-bounded by $\log_2{n}$, so that we have:
$$\sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} 2^i n^{2^{-i}} \leq \log_2{n} \sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} n^{2^{-i}}$$
Furthermore $n^{2^{-i}} \leq 1 + 2^{-i} n$ for all $i \geq 0$, so that:
$$\sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} n^{2^{-i}} \leq \sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} \left ( 1 + 2^{-i} n \right ) = \lceil \log_2{\log_2{n}} \rceil + n \sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} 2^{-i} \leq \lceil \log_2{\log_2{n}} \rceil + 2n$$
Which gives us:
$$\sum_{i = 0}^{\lceil \log_2{\log_2{n}} \rceil - 1} 2^i n^{2^{-i}} \leq 2n \log_2 n + \log_2 n \lceil \log_2{\log_2{n}} \rceil$$
Or, putting everything together:
$$f(n) \leq \left ( 2n + c' \right ) \log_2 n + \log_2 n \lceil \log_2{\log_2{n}} \rceil \in O \left ( n \log{n} \right )$$
Of course, it does grow slower than that as the ratio of $f(n)$ to its approximation tends to zero but I don't know how to obtain a tighter bound. (did you find a better one?) In any case, I don't know how to find an exact solution either, and I doubt a simple expression for it exists :(
 
  • #3
Assume that $n$ is a power of 2 then use the change of variable $n = 2^k $

$$f(2^k) = 2f(2^{k/2})+2^k $$

Now let $g(k) = f(2^k)$ so we have

$$g(k)= 2g\left( \frac{k}{2}\right)+2^k $$

Now if we use the Master theorem we get

$$g(k) = \Theta(2^k)$$

which implies that

$$f(n) = \Theta(n)$$
 
  • #4
Very sleek! I wonder if an exact solution exists now.. :confused:
 
  • #5
While all the other conditions of Case 3 of the Master Theorem hold, I don’t believe that the regularity condition,
$$ 2 \times 2^{k/2} \leq d \times 2^k, \ d < 1, \ k > N, $$
holds.
This holds for $ k \geq 2 \left (1-\log_{2} d \right ) $, but I don’t know…I’d like to have a numerical value for d that doesn’t depend on k. Maybe I’m wrong.
Anyway, I have a possible solution.
Starting from $ f(n) = 2 f(\sqrt n ) +n $, make the substitution $ n = 2^{2^k} $. The equation then becomes
$$ f \left ( 2^{2^k} \right ) = 2 f \left ( 2^{2^{k-1}} \right ) + 2^{2^k}. $$
Substituting $ g(k) = f \left ( 2^{2^k} \right ), $ the equation becomes
$$ g(k) = 2 g(k-1) +2^{2^k}. $$
Iterating, we see that
$$ g(k) = 4 g(k-2) + 3 \times 2^{2^k} = 8 g(k-3) + 7 \times 2^{2^k} = … $$
We see that
$$ g(k) = 2^c g(k-c) +\left ( 2^{c} -1 \right ) 2^{2^k} $$
for any c such that $ 1 \leq c \leq k. $
Iterating k times, we have that
$$ g(k) = 2^k g(0) +\left ( 2^{k} -1 \right ) 2^{2^k}. $$
Back substituting for $ g(k) $ and $ k $, we get
$$ f(n) = f(2) \log_{2} n +\left ( \log_{2} n -1 \right ) n. $$
Rearranging,
$$ f(n) = (f(2) +n ) \log_{2} n -n, n = 2^{2^k}. $$
 
Last edited:
  • #6
jacobi said:
While all the other conditions of Case 3 of the Master Theorem hold, I don’t believe that the regularity condition,
$$ 2 \times 2^{k/2} \leq d \times 2^k, \ d < 1, \ k > N, $$
holds.
This holds for $ k \geq 2 \left (1-\log_{2} d \right ) $, but I don’t know…I’d like to have a numerical value for d that doesn’t depend on k. Maybe I’m wrong.

You need to find only one value for $0<d<1$ such that the regularity condition holds. Here we can choose $d = 1/2$

$$ 2^{k/2} \leq 2^{k-2}, \ k > 4 $$

$$ g(k) = 4 g(k-2) + 3 \times 2^{2^k} = 8 g(k-3) + 7 \times 2^{2^k} = … $$

I don't see how you obtained the coefficients of $2^{2^k}$ ?
 
  • #7
ZaidAlyafey said:
You need to find only one value for $0<d<1$ such that the regularity condition holds. Here we can choose $d = 1/2$

$$ 2^{k/2} \leq 2^{k-2}, \ k > 4 $$

Oh, I see.

ZaidAlyafey said:
I don't see how you obtained the coefficients of $2^{2^k}$ ?
Since
$$ g(k) = 2 g(k-1) +2^{2^k}, $$
$$ g(k-1) = 2 g(k-2) + 2^{2^k}. $$
Substituting into the previous relation, we have that
$$ g(k) = 2 \left ( 2 g(k-2) +2^{2^k} \right ) +2^{2^k} = 4 g(k-2) + 2 \times 2^{2^k} + 2^{2^k} = 4 g(k-2) +3 \times 2^{2^k}. $$
Iterating c times, the coefficients of $ g(k-c) $ are $ 2^c $, and the coefficients of $ 2^{2^k} $ are $ 2^{c} - 1 $.
 
  • #8
jacobi said:
Oh, I see.Since
$$ g(k) = 2 g(k-1) +2^{2^k}, $$
$$ g(k-1) = 2 g(k-2) + \color{red}2^{2^k} $$

Ah, I think you missed to rewrite $2^{2^{k-1}}$
 
  • #9
(Swearing)(Swearing)(Swearing)
I can't believe I made such a stupid mistake. Forgetting to substitute $k-1$ for $k$...:mad:

Anyway, if you iterate CORRECTLY k times, you get
$$ g(k) = 2^k g(0) + \sum_{j=0}^{k} 2^j 2^{2^{k-j}}.$$
Then,
$$ f(n) = f(2) \log_{2} n + \sum_{j=0}^{\log_{2} \log_{2} n } 2^j n^{2^{-j}}, $$
which I can't find an exact expression for (yet).
 
Last edited:

FAQ: Finding an Exact Solution for the Recurrence Formula f(n) = 2f(sqrt(n)) + n

What is the function f(n)?

The function f(n) is a mathematical expression that takes a number n as its input and returns a corresponding output value. In this case, the function is defined as f(n) = 2f(sqrt(n)) + n.

What is the significance of the square root in the function?

The square root in the function represents the inverse operation of squaring a number. In this case, the function takes the square root of the input number and uses that value in the equation.

How do you solve the equation f(n) = 2f(sqrt(n))+n?

To solve this equation, you can use a process called iteration, where you substitute a value for n and use that value to calculate the output. This process can be repeated until a solution is found. Alternatively, you can use numerical methods such as Newton's method or bisection method to find the solution.

What is the purpose of the function f(n)?

The purpose of the function f(n) is to model a relationship between an input value (n) and an output value. It can be used to analyze and predict patterns in data, and to solve problems in various fields such as physics, engineering, and economics.

Are there any real-world applications of the function f(n)?

Yes, there are many real-world applications of the function f(n). For example, it can be used to model population growth, compound interest, and heat transfer in physics. It can also be used in computer science algorithms and data compression techniques.

Similar threads

Replies
2
Views
969
Replies
4
Views
2K
Replies
22
Views
4K
Replies
19
Views
3K
Replies
1
Views
1K
Replies
4
Views
931
Replies
1
Views
1K
Replies
3
Views
3K
Back
Top