3 ms·
It's not obvious when you should switch over to an approximation (base case), so I'd say it's not a good example to introduce recursion. I have never seen it, a
by gugagore 5y ago
It's not obvious when you should switch over to an approximation (base case), so I'd say it's not a good example to introduce recursion. I have never seen it, and I did not do it in school.
- aaaronic 5y agoWhen the difference between iterations is less than whatever threshold of accuracy you're looking for, I'd assume. "Relaxation" algorithms for calculating fields work that way.
- jhgb 5y agoIt's not obvious but that makes it a nice example in parameter optimization as well.
- scythe 5y agoIt's "obvious" if you remember how the Taylor series for sin(x) works. The error between x and sin(x) is bounded above by x^3/6. So there you go.
- SnowHill9902 5y agoFor a physicist sin(x) ~= x if x^3/6 << x