Message342837
| Author | serhiy.storchaka |
|---|---|
| Recipients | mark.dickinson, serhiy.storchaka |
| Date | 2019-05-19.07:16:22 |
| SpamBayes Score | -1.0 |
| Marked as misclassified | Yes |
| Message-id | <1558250182.76.0.794719861419.issue36957@roundup.psfhosted.org> |
| In-reply-to |
| Content | |
|---|---|
I have also some ideas about algorithmic optimizations (they need to be tested). In classic formula $a_{i+1} = a_i + (n - a_i^2)/(2*a_i)$ we can calculate $n - a_i^2$ as $(n - a_{i-1}^2) - (a_i^2 - a_{i-1})^2 = (n - a_{i-1}^2) - (a_i^2 - a_{i-1})*(a_i^2 + a_{i-1})$. $n - a_i^2$ usually is much smaller than $n$, so this can speed up subtraction and division. Things become more complicated when use shifts as in your formula, but I think that we can get benefit even in this case. This can also speed up the final check $a_i^2 <= n$. |
|
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2019-05-19 07:16:22 | serhiy.storchaka | set | recipients: + serhiy.storchaka, mark.dickinson |
| 2019-05-19 07:16:22 | serhiy.storchaka | set | messageid: <1558250182.76.0.794719861419.issue36957@roundup.psfhosted.org> |
| 2019-05-19 07:16:22 | serhiy.storchaka | link | issue36957 messages |
| 2019-05-19 07:16:22 | serhiy.storchaka | create | |