4 ms·
Are there a lot of systems that define arctangent but not pi?
by daveFNbuck 6y ago
Are there a lot of systems that define arctangent but not pi?
- gandalf013 6y agobc calculator doesn't (or didn't) define pi, but has atan. I've used "4*atan(1) method" in bc to get pi.
- ape4 6y agoThis works, `echo 'scale=100;4*a(1)' | bc -lq`
- kens 6y agoThe cheap Sinclair Scientific calculator (1974) was rather primitive, so instead of storing constants internally, it printed constants such as e and pi on the case. The calculator was rather inaccurate, so you were much better off using 3.14159 from the case than computing 4×atan(1), which gave 3.1440.
- taylodl 6y agoIt'd be interesting to see their implementation and the trade-offs its designers made.
- kens 6y agoI'm glad you asked :-) I reverse-engineered the Sinclair Scientific calculator, documented its code, and built a simulator: http://files.righto.com/calculator/sinclair_scientific_simulator.html http://files.righto.com/calculator/sinclair_scientific_simul... The short answer is that they used a 4-function calculator chip with just 320 words of ROM and managed to reprogram it into a cheap scientific calculator, a remarkable feat. The tradeoff was that the calculator was very slow and inaccurate.
- taylodl 6y agoThat's amazing! Thank you for sharing!
- taylodl 6y agoC/C++ don't define PI but have an atan function. According to the TIOBE Index for September 2020 (https://www.tiobe.com/tiobe-index/ https://www.tiobe.com/tiobe-index/) those languages are both in the top 5 of languages used by developers.
- votepaunchy 6y agoC++20 defines mathematical constants including Pi. https://en.cppreference.com/w/cpp/numeric/constants https://en.cppreference.com/w/cpp/numeric/constants
- taylodl 6y agoThanks for the heads up! I haven't been paying any attention to C++20. You must be on the cutting edge of C++ to know that - I ended up having to work a bit on my Macbook Pro to get a version of gcc working that defines std::numbers::pi.
- saagarjha 6y agoThey don’t but POSIX requires M_PI.
- xioxox 6y agoYes - Fortan doesn't have a built-in pi constant, but does have trigonometric functions. Usually programs define pi based on atan or some other trig relation.