Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tiagocavalcante/k-power-n-sum
Finds the formula for the sum of the kth powers of the first n natural numbers for any positive integer k
https://github.com/tiagocavalcante/k-power-n-sum
linear-algebra mathematics
Last synced: 12 days ago
JSON representation
Finds the formula for the sum of the kth powers of the first n natural numbers for any positive integer k
- Host: GitHub
- URL: https://github.com/tiagocavalcante/k-power-n-sum
- Owner: TiagoCavalcante
- License: mit
- Created: 2022-10-20T23:41:21.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-10-21T14:40:46.000Z (over 2 years ago)
- Last Synced: 2024-12-01T13:48:49.087Z (2 months ago)
- Topics: linear-algebra, mathematics
- Language: Python
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# k-power-n-sum
Finds the formula for the sum of the kth powers of the first n natural numbers for any positive integer k
## How it works?
This generates the augmented matrix for the linear system of the formula assuming that the formula of the sum of k-th powers is a polynomial of degree k + 1.
## How fast is it?
For small values of k this is very fast, but SymPy gets really slow with big values of k, if you care about performance I'd solve the linear system with C++, using the ideas from [this article](https://dspace.cvut.cz/bitstream/handle/10467/95144/F8-BP-2021-Eyvazov-Emil-Emil_Eyvazov_Thesis.pdf).
Just an idea abot the performance:
```sh
$ time python3 main.py
1^10 + ... + n^10 = n**11/11 + n**10/2 + 5*n**9/6 - n**7 + n**5 - n**3/2 + 5*n/66real 0m0.403s
user 0m0.351s
sys 0m0.052s$ time python3 main.py
1^200 + ... + n^200 = n**201/201 + n**200/2 + 50*n**199/3 - ...real 0m24.700s
user 0m24.545s
sys 0m0.154s
```