Created
May 29, 2021 06:38
-
-
Save genkuroki/6eea14d7d6593d46ece9afe777fbcf33 to your computer and use it in GitHub Desktop.
xsum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "a = sum(inv, 1:10^7)\nb = sum(inv, 10^7:-1:1)\nA = sum(inv∘big, 1:10^7)\nB = sum(inv∘big, 10^7:-1:1)\n\nc = sum(inv(k) for k in 1:10^7)\nd = sum(inv(k) for k in 10^7:-1:1)\nC = sum(inv(big(k)) for k in 1:10^7)\nD = sum(inv(big(k)) for k in 10^7:-1:1)\n\n@show a b c d A B C D", | |
"execution_count": 1, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "a = 16.69531136585985\nb = 16.69531136585985\nc = 16.695311365857272\nd = 16.695311365859965\nA = 16.6953113658598518153991189395404518842498697523730804627851359543562886921754\nB = 16.69531136585985181539911893954045188424986975237308046278513595435628869217375\nC = 16.69531136585985181539911893954045188424986975237308046278513595435628869215495\nD = 16.69531136585985181539911893954045188424986975237308046278513595435628869218591\n", | |
"name": "stdout" | |
}, | |
{ | |
"output_type": "execute_result", | |
"execution_count": 1, | |
"data": { | |
"text/plain": "16.69531136585985181539911893954045188424986975237308046278513595435628869218591" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "using Xsum\nxsum(inv, 1:10^7)", | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"execution_count": 2, | |
"data": { | |
"text/plain": "16.69531136585985" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "?xsum", | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "search: \u001b[0m\u001b[1mx\u001b[22m\u001b[0m\u001b[1ms\u001b[22m\u001b[0m\u001b[1mu\u001b[22m\u001b[0m\u001b[1mm\u001b[22m \u001b[0m\u001b[1mX\u001b[22m\u001b[0m\u001b[1ms\u001b[22m\u001b[0m\u001b[1mu\u001b[22m\u001b[0m\u001b[1mm\u001b[22m\n\n", | |
"name": "stdout" | |
}, | |
{ | |
"output_type": "execute_result", | |
"execution_count": 3, | |
"data": { | |
"text/plain": "\u001b[36m xsum([f,] itr)\u001b[39m\n\n Compute the exactly rounded double-precision sum of calling \u001b[36mf\u001b[39m (which\n defaults to \u001b[36midentity\u001b[39m) on the elements of the iterable collection \u001b[36mitr\u001b[39m. That\n is, return the sum as if (1) the elements of \u001b[36mf.(itr)\u001b[39m were converted to\n double (\u001b[36mFloat64\u001b[39m) precision, (2) summed in \u001b[4minfinite\u001b[24m precision, and (3)\n rounded to the closest double-precision value in the final result. Both real\n and complex sums are supported.", | |
"text/markdown": "```\nxsum([f,] itr)\n```\n\nCompute the exactly rounded double-precision sum of calling `f` (which defaults to `identity`) on the elements of the iterable collection `itr`. That is, return the sum as if (1) the elements of `f.(itr)` were converted to double (`Float64`) precision, (2) summed in *infinite* precision, and (3) rounded to the closest double-precision value in the final result. Both real and complex sums are supported.\n", | |
"text/latex": "\\begin{verbatim}\nxsum([f,] itr)\n\\end{verbatim}\nCompute the exactly rounded double-precision sum of calling \\texttt{f} (which defaults to \\texttt{identity}) on the elements of the iterable collection \\texttt{itr}. That is, return the sum as if (1) the elements of \\texttt{f.(itr)} were converted to double (\\texttt{Float64}) precision, (2) summed in \\emph{infinite} precision, and (3) rounded to the closest double-precision value in the final result. Both real and complex sums are supported.\n\n" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "julia-1.7-depwarn-o3", | |
"display_name": "Julia 1.7.0-DEV depwarn -O3", | |
"language": "julia" | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"base_numbering": 1, | |
"title_cell": "Table of Contents", | |
"title_sidebar": "Contents", | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": true, | |
"toc_window_display": false | |
}, | |
"language_info": { | |
"file_extension": ".jl", | |
"name": "julia", | |
"mimetype": "application/julia", | |
"version": "1.7.0" | |
}, | |
"@webio": { | |
"lastKernelId": null, | |
"lastCommId": null | |
}, | |
"gist": { | |
"id": "6eea14d7d6593d46ece9afe777fbcf33", | |
"data": { | |
"description": "xsum", | |
"public": true | |
} | |
}, | |
"_draft": { | |
"nbviewer_url": "https://gist.github.com/6eea14d7d6593d46ece9afe777fbcf33" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment