This journal is available for random discussion topics of interest to the community, with just a few rules:
1) No personal attacks, grumbling about site policy, or complaining about other users and the staff.
2) No racism, bigotry, or culture wars of any kind.
3) No politics of any kind. There are plenty of other places to discuss this topic. Policy discussion is okay, though, as long as it focuses on the issues instead of people or parties. Be sure to follow rule #2 here.
4) No random spamming. If you're an member of the site who intends to regularly contribute and participate, and you wish to discuss your personal projects, that's fine. If you're a drive-by spammer who's here just to promote your business or hosts file software, get lost.
5) Please be kind to each other.
Otherwise, you're welcome to discuss anything you'd like in this journal.
(Score: 0) by Anonymous Coward on Thursday September 05, @06:11AM (3 children)
For those that don't know, that's not how successive approximation works. You are supposed to start with the general value and work your way towards the specific value. You can do that with a number of algorithms. There are ones that work specifically for different operations in better than worse case. However, what I really wanted to do was to inform everyone of my favorite one using the Farey Tree.
So to calculate answer to your operation you start with your lower and upper bound for your operation. You find the new of bounds with four steps. First, match fractions as a/c and b/d. Second, find the mediant ((a+b) / (c+d)). Third, test if your new fraction is higher or lower than the answer you seek. Finally, replace the respective bounds. Then keep going until the desired precision is reached or you get tired of waiting.
So for the square root of 2. The bounds of square root are 1 and the operand, 1/1 and 2/1. Calculate the mediant ((1+2)/(1+1)) == 3/2. 3/2 squared is 9/4 and is higher than 2 so the original fraction is higher than the square root of 2. So you replace the high bound. The bounds are now 1/1 and 3/2. The new mediant is 4/3rds. 4/3 squared is 16 / 9, which is lower than 2, so the lower bound is replaced and they are now 4/3 and 3/2. Keep going until you are close enough.
I like this one because I find it easier to understand and do than many of the alternatives. Yes, it often approaches worst case performance, but I find the ability to understand it, do it in my head quickly, and to start anywhere worth the trade off.
(Score: 1, Interesting) by Anonymous Coward on Thursday September 05, @06:28AM
I should include an example code and calculation:
Example python code:
Example calculating square root of two:
Example of calculating pi but without the 3 in front to make the math easier:
(Score: 3, Insightful) by DannyB on Thursday September 05, @08:42PM (1 child)
^{<no-sarcasm>}
Many decades ago, in the late 1970s, in high school, I figured this out with a calculator that did not have a square root operation. I came up with a guess of 1.5, squared it . . . too high. Tried 1.4 . . . too low. Tried 1.45, 1.44, etc.
_{</no-sarcasm>}
In my old age I find that my new method of successive approximation is more amusing.
The thing to remember about the saying "you are what you are" is, that saying: is what it is.
(Score: 1, Funny) by Anonymous Coward on Thursday September 05, @10:34PM
As do I. But in my old age, I find it harder to resist the urge to share information I find interesting. Stuck between two haystacks, this old ass chose his standby.