sqrt(2)
Project description
SquareRoot2Py
https://www.youtube.com/watch?v=ktRwfBMV4S8
The SquareRoot2Py
package aims to remove the hassle of computing the square root of 2.
Features
- computing the square root of 2
- up to 16 decimal places of precision
- cross-platform support
- O(1) algorithm
- clear and concise naming
Installation
pip install SquareRoot2Py
Benchmark
Our state-of-the-art algorithm computes the rounded value of the square root of 2 almost 2x faster than the built-in C implementation.
Built-in C implementation
>>> timeit("a = round(2 ** 0.5)", number=10000000)
0.46002930000031483
SquareRoot2Py
>>> timeit("a = SquareRoot2Py.RoundedSquareRoot2Py.compute_rounded_square_root_of_2()", setup="import SquareRoot2Py.RoundedSquareRoot2Py", number=10000000)
0.26070590000017546
Examples
To compute the square root of 2 easily:
import SquareRoot2Py
print(SquareRoot2Py.compute_square_root_of_2())
If you would like to round the result:
import SquareRoot2Py.RoundedSquareRoot2Py
print(RoundedSquareRoot2Py.compute_rounded_square_root_of_2())
For more complex usecases such as calculating the US Government Budget, adjustable rounding can be used:
import SquareRoot2Py.SquareRoot2PyWithAdjustableRounding
print(SquareRoot2Py.SquareRoot2PyWithAdjustableRounding.compute_square_root_of_2_with_adjustable_rounding(3))
We are aware that the name SquareRoot2Py.SquareRoot2PyWithAdjustableRounding
might be too long
Therefore, the following alias is introduced:
import SquareRoot2Py
print(SquareRoot2Py.WithAdjustableRounding.compute_square_root_of_2_with_adjustable_rounding())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
squareroot2py-2.1.0.tar.gz
(39.5 kB
view hashes)
Built Distribution
Close
Hashes for SquareRoot2Py-2.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd150d2546e81f5cc30580ab51798a713d85fad48198fdbbf6251b8ee27d51f0 |
|
MD5 | ebe256d3e2c95c620fd0826d1b98c2ad |
|
BLAKE2b-256 | 734dcf3c2dd5f78fece73b75fbaf53d83684f2e6fabecf86d5f85f6a42487654 |