Task 34 Precision issues

Back to General discussions forum

patolucatis     2022-09-22 14:27:27

I'm trying to solve task 34, binary search, and I've come up with the algorithm in both Python and Rust, but I can't seem to be able to get the precision required.

In the Python's algorithm case, I can do 5 decimals before the program gets stuck, and in Rust, I managed to reach 6.

Any ideas that could help me optimize things in general? I'd post code, but I don't want to spoil my solution to others.

zelevin     2022-09-22 14:35:20

I would print intermediate values as they converge. I suspect you might have an issue with either a stopping criterion or shrinking the interval. Generally speaking, for binary search convergence is quick (i.e., the speed of the algorith should be linear with the number of the digits of precision).

patolucatis     2022-09-22 14:56:15

Okay, in the end the issue was mine, as I had messed up the algorithm. Thanks for the help, though!

JesseDai     2022-09-22 15:10:21
User avatar

Hello! What do you mean by stuck? Also, is the version here your most up-to-date version?

JesseDai     2022-09-22 15:10:49
User avatar

Nevermind xD Spent too long on making message.

Please login and solve 5 problems to be able to post at forum