Task 34 Precision issues
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
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.
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).
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK