How do you calculate recursive efficiency?

  • Thread starter David Carroll
  • Start date
  • Tags
    Efficiency
In summary, the conversation discusses the efficiency of recursive formulas and how to calculate and prove their efficiency. It also mentions the concept of recursive efficiency and converting recursive solutions to iterative ones. Additionally, it mentions the use of O(n) notation and finding the composition of a function with itself to determine efficiency. The conversation concludes with the speaker finding a non-recursive solution for their problem and briefly mentioning the concept of rate of convergence.
  • #1
David Carroll
181
13
Greetings ladies and gentlemen.

I am right now working on a recursive formula whose nature I'll define later. Unfortunately, I have no formal education in math. What I want is some references to where I can find how to calculate the efficiency of a recursive formula and how to prove its efficiency.

For example (though this is not the formula I'm working with), consider the algorithm to find the square root of a number: Step 1: Divide x2 by any number. Step 2: Take the arithmetic mean of the output number and the original input number and divide x2 by this arithmetic mean. Repeat step 2 until the output differs by its corresponding input by zero at D decimal places, where D is the number of decimal places that fits on some calculating device.

How is the efficiency of the above recursive formula defined and calculated? How is the efficiency of any recursive formula defined and calculated?
 
Mathematics news on Phys.org
  • #2
A numerical algorithm may quickly converge to the answer for some inputs (for example divide 4 by 2 to estimate its square root) and slowly converge to an answer for others. So you can begin by deciding what you care about - best case performance? worst case performance? You can attempt to deal with "average case performance", but this can get complicated because you must specify what you mean by "average". Do you have some way of defining a probability distribution for the inputs that are chosen?
 
  • #3
David Carroll said:
How is the efficiency of the above recursive formula defined and calculated? How is the efficiency of any recursive formula defined and calculated?
Never heard of a term "recursive efficiency". But wait, I remembered something, maybe it will be of some help. I know recursive algorithms encoded in a some programming language require more RAM to be executed. It is easier (and shorter way) for a programmer but harder for a machine.
 
Last edited:
  • #4
There's a certain fact that struck me as profound and enlightening when I first learned of it:

"Any recursive function has an iterative counterpart, and any iterative function has a recursive counterpart."

Convert your recursive solution to an iterative one. Then, use O(n) notation to analyze and formally mark the efficiency of your algorithm. Whatever complexity the iterative form is, the same complexity will embody the recursive form.

If you know exactly how many times something will loop, (and sometimes, even when you don't), you can put the computation in a 'closed-form'. The following code outputs your sqrt(x) example after four iterations, assuming an initial guess of 'x'.

input x
A = x+1
B = A^2
C = 4*x

output ( (C+B)^2+32*x*B ) / ( 8*A*(C+B) )

You can find that by finding the composition of the initial function of step 2 with itself a few times.
 
Last edited:
  • Like
Likes David Carroll
  • #5
Thanks guys. Actually, this is all a moot point. I found a non-recursive way to deal with what I'm working on.

o:)
 
  • #6
I guess you looked for rate of convergence.

As examples, a linear convergence will add the same number of significant digits per step, while a quadratic convergence (like the mentioned square root finding method) will double the number of significant digits each n steps.
 

1. What is recursive efficiency?

Recursive efficiency is a measure of how well a recursive algorithm performs in terms of time and space complexity. It refers to the amount of time and memory required for a recursive algorithm to solve a problem.

2. How is recursive efficiency calculated?

Recursive efficiency is typically calculated by analyzing the number of recursive calls and the complexity of each call. This can be done through mathematical analysis or by using tools such as Big O notation.

3. What is the significance of calculating recursive efficiency?

Calculating recursive efficiency is important because it allows us to evaluate the performance of a recursive algorithm and compare it to other algorithms for solving the same problem. It also helps us identify areas for improvement and optimize the algorithm.

4. Can recursive efficiency be improved?

Yes, recursive efficiency can be improved through various techniques such as tail recursion, memoization, and dynamic programming. These techniques help reduce the number of recursive calls and improve the overall performance of the algorithm.

5. Are there any limitations to calculating recursive efficiency?

While calculating recursive efficiency is a useful tool for evaluating algorithms, it does have some limitations. It may not always accurately reflect the actual performance of an algorithm due to factors such as hardware limitations, input data, and implementation details.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
11
Views
903
Replies
12
Views
2K
Replies
4
Views
429
  • Introductory Physics Homework Help
Replies
4
Views
909
Replies
7
Views
1K
Replies
28
Views
3K
  • General Math
Replies
5
Views
851
  • Engineering and Comp Sci Homework Help
Replies
19
Views
2K
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
8
Views
1K
Back
Top