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
Built Distribution
File details
Details for the file squareroot2py-2.1.0.tar.gz
.
File metadata
- Download URL: squareroot2py-2.1.0.tar.gz
- Upload date:
- Size: 39.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c247994922a514ce36a194d16ca22d6580ae5ede8a606486b959a51cce172a2 |
|
MD5 | 69122c5c74f6a12395389b126949b648 |
|
BLAKE2b-256 | d01cc75f65b87f8a9a47b3d0cac1e0faa66828ee0dffe7c203c82b5affb0f4ba |
File details
Details for the file SquareRoot2Py-2.1.0-py3-none-any.whl
.
File metadata
- Download URL: SquareRoot2Py-2.1.0-py3-none-any.whl
- Upload date:
- Size: 27.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd150d2546e81f5cc30580ab51798a713d85fad48198fdbbf6251b8ee27d51f0 |
|
MD5 | ebe256d3e2c95c620fd0826d1b98c2ad |
|
BLAKE2b-256 | 734dcf3c2dd5f78fece73b75fbaf53d83684f2e6fabecf86d5f85f6a42487654 |