Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I found the thing about iteration quite strange.

To iterate, we need to know if our mediant is larger or smaller than the true value.

How do we know that?

Edit: elsewhere in the thread someone explained that the purpose of iterating is to find an approximation with small denominator.



e isn't the best example for this, because you would need a good decimal expansion. But say we're trying to approximate sqrt(2) by this method. Say we've already established that it's in the interval [7/5, 10/7]. We can verify because 7^2 < 2*5^2 and 10^2 > 2*7^2. Then the mediant is 17/12, and since 17^2 = 289 > 288 = 2*12^2, we know 17/12 > sqrt(2). So [7/5, 17/12] is a smaller interval containing sqrt(2). Repeating this, [24/17, 17/12] is even better, and so on.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: