3

Task 34 Precision issues

 1 year ago
source link: https://www.codeabbey.com/index/forum_topic/c2847f75c70354b95fcce919ade15708
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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).

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

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK