{"id":18376241,"url":"https://github.com/bunji2/gointegral","last_synced_at":"2026-04-17T05:03:32.576Z","repository":{"id":95709817,"uuid":"240725651","full_name":"bunji2/gointegral","owner":"bunji2","description":"gointegral --- golang implementation of Simpson method (described in Japanese)","archived":false,"fork":false,"pushed_at":"2020-04-20T14:14:40.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T21:46:50.777Z","etag":null,"topics":["golang","integral-equations","javascript","simpson-method"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bunji2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-15T14:21:59.000Z","updated_at":"2020-04-20T14:14:42.000Z","dependencies_parsed_at":"2023-05-21T17:15:26.458Z","dependency_job_id":null,"html_url":"https://github.com/bunji2/gointegral","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bunji2/gointegral","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bunji2%2Fgointegral","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bunji2%2Fgointegral/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bunji2%2Fgointegral/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bunji2%2Fgointegral/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bunji2","download_url":"https://codeload.github.com/bunji2/gointegral/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bunji2%2Fgointegral/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267029422,"owners_count":24024202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","integral-equations","javascript","simpson-method"],"created_at":"2024-11-06T00:22:27.963Z","updated_at":"2026-04-17T05:03:27.531Z","avatar_url":"https://github.com/bunji2.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gointegral --- golang implementation of Simpson method\n\nシンプソン法の golang 実装。\n\n十分小さな区間 \n\u003c!--\n![](https://latex.codecogs.com/gif.latex?[x_i,x_{i+1}])\n--\u003e\n![](0.gif)\n  における関数 \n\u003c!--\n![](https://latex.codecogs.com/gif.latex?f(x))\n--\u003e\n![](1.gif)\n の定積分は、次の近似式で与えられる。\n\n\u003c!--\n![](https://latex.codecogs.com/gif.latex?\\int_{x_i}^{x_{i\u0026plus;1}}f(x)dx\\approx\\frac{1}{6}(x_{i\u0026plus;1}-x_i)(f(x_i)\u0026plus;4f(\\frac{x_i\u0026plus;x_{i\u0026plus;1}}{2})\u0026plus;f(x_{i\u0026plus;1})))\n--\u003e\n![](2.gif)\n\n区間 \n\u003c!--\n![](https://latex.codecogs.com/gif.latex?[a,b])\n--\u003e\n![](3.gif)\n の定積分であれば、区間を N 等分した十分に小さな区間 \n\u003c!--\n![](https://latex.codecogs.com/gif.latex?[x_i,x_{i+1}])\n--\u003e\n![](4.gif)\n の定積分の合計と考えればよい。\n\n\u003c!--\n![](https://latex.codecogs.com/gif.latex?x_i=a\u0026plus;\\frac{b-a}{N}i)\n--\u003e\n![](5.gif)\n where \n\u003c!--\n![](https://latex.codecogs.com/gif.latex?(0\\leq{i}\u003cN))\n--\u003e\n![](6.gif)\n\n\u003c!--\n![](https://latex.codecogs.com/gif.latex?%5Cint_%7Ba%7D%5E%7Bb%7Df%28x%29dx%5Capprox%5Csum_%7Bi%3D0%7D%5E%7BN-1%7D%5Cleft%5C%7B%5Cfrac%7B1%7D%7B6%7D%28x_%7Bi\u0026plus;1%7D-x_i%29%28f%28x_i%29\u0026plus;4f%28%5Cfrac%7Bx_i\u0026plus;x_%7Bi\u0026plus;1%7D%7D%7B2%7D%29\u0026plus;f%28x_%7Bi\u0026plus;1%7D%29%29%5Cright%5C%7D)\n--\u003e\n![](7.gif)\n\n----\n\ngointegral では積分区間 interval、区間を等分する個数 N、積分対象とする関数 f を JavaScript のコードで与える。\n\n例として、sin 関数の[0,π] 区間での定積分では次のような JavaScript コードを使う。\n\n```javascript\n// sin.js\n\n// 積分区間 [a, b]\nvar interval = [0, Math.PI];\n\n// 区間等分数 N\nvar n = 1000;\n\n// 積分の対象とする関数 f(x)\nfunction f(x) {\n    return Math.sin(x);\n}\n```\n\ngointegral の使い方は次の通りである。 \n\n```\n$ ./gointegral sin.js\ninterval = [0 3.141592653589793]\nn = 1000\nresult = 1.999995065201925\n$ \n```\n\n積分結果がわかっていて、シンプソン法のエラー率[%]を求めたい場合には、次のように answer 変数を指定する。\n\n```javascript\n// 積分区間 [a, b]\nvar interval = [0, Math.PI];\n\n// 区間等分数 N\nvar n = 1000;\n\n// 積分の対象とする関数 f(x)\nfunction f(x) {\n    return Math.sin(x);\n}\n\n// エラー率[%]を算出するための正しい積分結果の指定 \nvar answer = 2;\n```\n\n実行結果は以下のとおりである。\n\n```\n$ ./gointegral sin.js\ninterval = [0 3.141592653589793]\nn = 1000\nresult = 1.999995065201925\nanswer = 2\nerror  = 0.0002467399037531237 [%]\n```\n\n----\nいくつか実行例を示す。\n\n\u003c!--\n![](https://latex.codecogs.com/gif.latex?I%3D%5Cint_%7B0%7D%5E%7B1%7D5x%5E4dx)\n--\u003e\n![](8.gif)\n\n```javascript\n// 積分区間\nvar interval = [0, 1];\n\n// 区間等分数 N\nvar n = 1000;\n\n// 積分対象の関数\nfunction f(x) {\n    return 5*Math.pow(x, 4);\n}\n\n// エラー率を算出するための正しい積分結果の指定 \nvar answer = 1;\n```\n\n実行結果：\n\n```\ninterval = [0 1]\nn = 1000\nresult = 1.0000000000000449\nanswer = 1\nerror  = 4.4853010194856324e-12 [%]\n```\n\n----\n\n\u003c!--\n![](https://latex.codecogs.com/gif.latex?I%3D%5Cint_%7B0%7D%5E%7B2%5Cpi%7D%7C%5Ccos%28x%29%7Cdx)\n--\u003e\n![](9.gif)\n\n```javascript\n// 積分区間\nvar interval = [0, 2*Math.PI];\n\n// 区間等分数\nvar n = 1000;\n\n// 積分対象の関数\nfunction f(x) {\n    return Math.abs(Math.cos(x));\n}\n\n// エラー率を算出するための正しい積分結果の指定 \nvar answer = 4;\n```\n\n実行結果：\n\n```\ninterval = [0 6.283185307179586]\nn = 1000\nresult = 4.006283143967614\nanswer = 4\nerror  = 0.15707859919034117 [%]\n```\n\n----\n\n\u003c!--\n![](https://latex.codecogs.com/gif.latex?I=\\int_{\\sqrt{2}}^2\\left(\\frac{1}{x\\sqrt{x^2-1}}\\right)dx)\n--\u003e\n![](10.gif)\n\n```javascript\n// 積分区間\nvar interval = [Math.sqrt(2), 2];\n\n// 区間等分数\nvar n = 1000;\n\n// 積分対象の関数\nfunction f(x) {\n    return 1/(x*Math.sqrt(Math.pow(x, 2)-1));\n}\n\n// エラー率を算出するための正しい積分結果の指定 \nvar answer = Math.PI/12;\n```\n\n実行結果：\n\n```\ninterval = [1.4142135623730951 2]\nn = 1000\nresult = 0.26196843201518166\nanswer = 0.2617993877991494\nerror  = 0.06457013419830616 [%]\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbunji2%2Fgointegral","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbunji2%2Fgointegral","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbunji2%2Fgointegral/lists"}