{"id":4749,"date":"2025-03-31T13:43:49","date_gmt":"2025-03-31T04:43:49","guid":{"rendered":"https:\/\/www.ktech.biz\/jp\/?p=4749"},"modified":"2025-05-05T20:24:08","modified_gmt":"2025-05-05T11:24:08","slug":"6-alg","status":"publish","type":"post","link":"https:\/\/www.ktech.biz\/jp\/tutorial\/6-alg\/","title":{"rendered":"6. \u4ee3\u6570\u65b9\u7a0b\u5f0f"},"content":{"rendered":"\n<h3>6.1 \u6982\u8981<\/h3>\n<p>\u4ee3\u6570\u65b9\u7a0b\u5f0f\u3068\u306f\u591a\u9805\u5f0f\u306e\u30bc\u30ed\u70b9\u3092\u6c42\u3081\u308b\u554f\u984c\u3067\u3059.<br \/>\n\\[<br \/>\np(x) = a_0x^n + a_1x^{n-1} + \\dots + a_{n-1}x + a_n = 0<br \/>\n\\]\n\u3088\u304f\u77e5\u3089\u308c\u3066\u3044\u308b\u3088\u3046\u306b 2, 3, 4 \u6b21\u65b9\u7a0b\u5f0f\u306b\u3064\u3044\u3066\u306f\u89e3\u306e\u516c\u5f0f\u3067\u89e3\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059. 5 \u6b21\u4ee5\u4e0a(\u9ad8\u6b21\u4ee3\u6570\u65b9\u7a0b\u5f0f)\u306f\u4e00\u822c\u7684\u306b\u306f\u6570\u5024\u89e3\u6cd5(\u53cd\u5fa9\u6cd5)\u3067\u89e3\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059. \u306a\u304a, 3, 4 \u6b21\u3067\u3042\u3063\u3066\u3082\u6570\u5024\u89e3\u6cd5\u3067\u89e3\u3044\u305f\u65b9\u304c\u3088\u3044\u5834\u5408\u3082\u3042\u308a\u307e\u3059.<\/p>\n<h3>6.2 \u9ad8\u6b21\u4ee3\u6570\u65b9\u7a0b\u5f0f\u306e\u89e3\u6cd5<\/h3>\n<p>\u9ad8\u6b21\u4ee3\u6570\u65b9\u7a0b\u5f0f\u306b\u3064\u3044\u3066\u306f\u591a\u304f\u306e\u89e3\u6cd5\u304c\u63d0\u6848\u3055\u308c\u3066\u304d\u307e\u3057\u305f. \u4f8b\u3048\u3070, \u30d9\u30a2\u30b9\u30c8\u30a6\u6cd5, \u30b0\u30ec\u30c3\u30d5\u30a7\u6cd5, \u30d9\u30eb\u30cc\u30fc\u30a4\u6cd5, \u30b8\u30a7\u30f3\u30ad\u30f3\u30b9\u30fb\u30c8\u30e9\u30a6\u30d6\u6cd5\u306a\u3069\u3067\u3059\u304c, \u6c7a\u5b9a\u7248\u3068\u3044\u3046\u3088\u3046\u306a\u89e3\u6cd5\u306f\u306a\u304b\u3063\u305f\u3088\u3046\u3067\u3059.<\/p>\n<p>\u7279\u5b9a\u306e\u89e3\u3092\uff11\u3064\u3060\u3051\u6c42\u3081\u308c\u3070\u3088\u3044\u5834\u5408\u306b\u306f 1 \u5909\u6570\u306e\u975e\u7dda\u5f62\u65b9\u7a0b\u5f0f\u3068\u3057\u3066\u30cb\u30e5\u30fc\u30c8\u30f3\u6cd5\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059. \u305f\u3060\u3057, \u3088\u3044\u521d\u671f\u5024\u304c\u308f\u304b\u3063\u3066\u3044\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059.<\/p>\n<p>\u3059\u3079\u3066\u306e\u89e3\u3092\u6c42\u3081\u305f\u3044\u5834\u5408\u306b\u306f\u6b21\u306e\u3088\u3046\u306a\u89e3\u6cd5\u304c\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059.<\/p>\n<h4>6.2.1 \u9023\u7acb\u6cd5<\/h4>\n<p>\u3059\u3079\u3066\u306e\u89e3\u3092\u540c\u6642\u306b\u6c42\u3081\u308b\u53cd\u5fa9\u6cd5\u3067\u3059.<\/p>\n<p>\\(k\\) \u756a\u76ee\u306e\u53cd\u5fa9\u306e\u8fd1\u4f3c\u89e3\u3092\u4e0a\u4ed8\u304d\u306e \\((k)\\) \u3067\u8868\u3059\u3053\u3068\u306b\u3059\u308b\u3068, \u305d\u308c\u305e\u308c\u306e\u89e3\u3092\u30cb\u30e5\u30fc\u30c8\u30f3\u6cd5\u3067\u6c42\u3081\u308b\u3068\u304d\u306e\u53cd\u5fa9\u5f0f\u306f\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059.<br \/>\n\\[<br \/>\nx_i^{(k+1)} = x_i^{(k)} &#8211; p(x_i^{(k)})\/p'(x_i^{(k)})<br \/>\n\\]\n\u3053\u3053\u3067, \\(p'(x_i^{(k)}) \\simeq \\prod_{j=1}^{n, j \\neq i}(x_i^{(k)} &#8211; x_j^{(k)})\\) \u3067\u8fd1\u4f3c\u3059\u308b\u3068\u6b21\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059.<br \/>\n\\[<br \/>\nx_i^{(k+1)} = x_i^{(k)} &#8211; p(x_i^{(k)})\/\\prod_{j=1}^{n, j \\neq i}(x_i^{(k)} &#8211; x_j^{(k)})<br \/>\n\\]\n\u3053\u308c\u306f\u9023\u7acb\u6cd5 (2 \u6b21\u6cd5) \u3068\u547c\u3070\u308c, \u91cd\u6839\u304c\u306a\u3051\u308c\u3070 2 \u6b21\u53ce\u675f\u3057\u307e\u3059. \u30c7\u30e5\u30e9\u30f3\u30fb\u30b1\u30eb\u30ca\u30fc\u6cd5\u3068\u547c\u3070\u308c\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059.<\/p>\n<p>\u8fd1\u4f3c\u306e\u4ed5\u65b9\u3084\u521d\u671f\u5024\u306e\u4e0e\u3048\u65b9\u306b\u306f\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u304c\u3042\u308a\u307e\u3059. \u5c11\u3057\u8a08\u7b97\u91cf\u304c\u5897\u3048\u308b\u3082\u306e\u306e, \u91cd\u6839\u304c\u306a\u3051\u308c\u3070 3 \u6b21\u53ce\u675f\u3059\u308b\u8fd1\u4f3c\u5f0f\u3082\u3042\u308a 3 \u6b21\u6cd5\u3068\u547c\u3076\u3053\u3068\u304c\u3042\u308a\u307e\u3059. \u30a2\u30d0\u30fc\u30b9\u304c\u63d0\u6848\u3057\u305f\u521d\u671f\u5024\u3092\u63a1\u7528\u3057\u305f\u3082\u306e\u306f\u30c7\u30e5\u30e9\u30f3\u30fb\u30b1\u30eb\u30ca\u30fc\u30fb\u30a2\u30d0\u30fc\u30b9 (DKA) \u6cd5\u3068\u547c\u3070\u308c\u307e\u3059.<\/p>\n<h4>6.2.2 \u968f\u4f34\u884c\u5217\u6cd5<\/h4>\n<p>\u56fa\u6709\u5024\u554f\u984c\u306b\u304a\u3044\u3066\u300c\u56fa\u6709\u5024 \\(\\lambda\\) \u306b\u95a2\u3059\u308b n \u6b21\u4ee3\u6570\u65b9\u7a0b\u5f0f\u3092\u7279\u6027\u65b9\u7a0b\u5f0f\u3068\u547c\u3073, \u3053\u308c\u3092\u89e3\u3051\u3070\u56fa\u6709\u5024\u304c\u6c42\u3081\u3089\u308c\u308b\u300d\u3068\u3044\u3046\u3088\u3046\u306a\u89e3\u8aac\u304c\u3055\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059. \u5b9f\u969b\u306b\u306f\u9006\u3067, \u4ee3\u6570\u65b9\u7a0b\u5f0f\u3092\u76f4\u63a5\u89e3\u304f\u65b9\u304c\u96e3\u3057\u3044\u305f\u3081, \u89e3\u304f\u3079\u304d\u4ee3\u6570\u65b9\u7a0b\u5f0f\u306b\u5bfe\u5fdc\u3059\u308b\u56fa\u6709\u5024\u554f\u984c\u3092\u7d44\u307f\u7acb\u3066\u3066 (\u968f\u4f34\u884c\u5217\u3068\u3044\u3046) \u305d\u308c\u3092 QR \u6cd5\u306a\u3069\u306e\u56fa\u6709\u5024\u554f\u984c\u306e\u89e3\u6cd5\u3067\u89e3\u304f\u3053\u3068\u306b\u3088\u308a\u9593\u63a5\u7684\u306b\u4ee3\u6570\u65b9\u7a0b\u5f0f\u306e\u89e3\u3092\u6c42\u3081\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059.<\/p>\n<h3>6.3 XLPack \u3092\u4f7f\u3063\u305f\u4ee3\u6570\u65b9\u7a0b\u5f0f\u306e\u89e3\u304d\u65b9<\/h3>\n<p>VBA \u30b5\u30d6\u30eb\u30fc\u30c1\u30f3 <strong>Rpzero2<\/strong> \u306f\u5b9f\u6570\u4fc2\u6570\u306e\u4ee3\u6570\u65b9\u7a0b\u5f0f\u3092\u9023\u7acb\u6cd5(2 \u6b21\u6cd5)\u3067\u89e3\u304f\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059. \u8907\u7d20\u89e3\u304c\u3042\u308c\u3070\u305d\u308c\u3082\u6c42\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059. \u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u95a2\u6570\u3068\u3057\u3066\u306f <strong>WRpzero2<\/strong> \u304c\u4f7f\u7528\u3067\u304d\u307e\u3059.<\/p>\n<h5>\u4f8b\u984c<\/h5>\n<p>\u6b21\u306e 5 \u6b21\u65b9\u7a0b\u5f0f\u3092\u89e3\u304f.<br \/>\n\\[<br \/>\nx^5 + 2x^3 + 2x^2 &#8211; 15x + 10 = 0<br \/>\n\\]\n\u3053\u308c\u306f\u56e0\u6570\u5206\u89e3\u3067\u304d\u3066,<br \/>\n\\[<br \/>\n(x &#8211; 1)^2(x + 2)(x^2 + 5) = 0<br \/>\n\\]\n\u3068\u306a\u308b\u306e\u3067, \u89e3\u306f \\(1(\u91cd\u6839), -2, \\pm\\sqrt{5}i\\) \u3068\u306a\u308b\u3053\u3068\u304c\u308f\u304b\u3063\u3066\u3044\u307e\u3059.<\/p>\n<h4>6.3.1 \u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u95a2\u6570\u3092\u4f7f\u7528\u3057\u305f\u89e3\u304d\u65b9<\/h4>\n<p>\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u306e\u9069\u5f53\u306a\u5834\u6240\u306b\u4ee3\u6570\u65b9\u7a0b\u5f0f\u306e\u4fc2\u6570 \\(a_i\\) \u3092\u5165\u529b\u3057\u307e\u3059(\u30aa\u30ec\u30f3\u30b8\u8272\u306e\u30bb\u30eb). \u6b21\u306b, \u89e3 \\((x(r), x(i))\\) \u304a\u3088\u3073 \u8aa4\u5dee\u9650\u754c \\(s(i)\\) \u3092\u5165\u308c\u308b\u305f\u3081\u306e\u30bb\u30eb\u3092 \\((n + 1) \\times 3\\) \u30bb\u30eb\u9078\u629e\u3057\u3066\u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u95a2\u6570 <strong>WRpzero2<\/strong> \u3092\u5165\u529b\u3057\u307e\u3059(\u7dd1\u8272\u306e\u30bb\u30eb).<\/p>\n<p><strong>WRpzero2<\/strong> \u306e\u5fc5\u8981\u306a\u30d1\u30e9\u30e1\u30fc\u30bf\u306f N \u304a\u3088\u3073 A \u3067\u3059. N \u306f\u65b9\u7a0b\u5f0f\u306e\u6b21\u6570(\u3053\u306e\u4f8b\u3067\u306f 5), A \u306f\u65b9\u7a0b\u5f0f\u306e\u4fc2\u6570\u306e\u30bb\u30eb\u7bc4\u56f2\u3067\u3059. \u3053\u3053\u3067, \u65b9\u7a0b\u5f0f\u3092 \\(a_0 x^n + a_1x^{n-1} + \\dots + a_{>n-1}x + a_n = 0\\) \u3068\u3059\u308b\u3068, \u4fc2\u6570\u306f\u5b9f\u6570 \\(a_0, a_1, \\dots, a_n\\) \u3067\u8868\u3055\u308c\u307e\u3059.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_1.png\" alt=\"\" width=\"961\" height=\"692\" class=\"aligncenter size-full wp-image-5118\" srcset=\"https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_1.png 961w, https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_1-300x216.png 300w, https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_1-768x553.png 768w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/p>\n<p>\u5165\u529b\u304c\u7d42\u4e86\u3057\u305f\u3089 Ctrl + Shift + Enter \u3092\u62bc\u3057\u307e\u3059. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_2.png\" alt=\"\" width=\"956\" height=\"689\" class=\"aligncenter size-full wp-image-5119\" srcset=\"https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_2.png 956w, https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_2-300x216.png 300w, https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2025\/08\/Ex6W_2-768x554.png 768w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/p>\n<p>\u3053\u308c\u3067, 5 \u3064\u306e\u89e3\u304c\u6b63\u3057\u304f\u6c42\u3081\u3089\u308c\u307e\u3057\u305f. \u306a\u304a, \u4e00\u756a\u53f3\u306e\u5217 s(i) \u306f\u8aa4\u5dee\u9650\u754c, \u4e00\u756a\u4e0b\u306e\u884c\u306f\u5de6\u304b\u3089\u30ea\u30bf\u30fc\u30f3\u30b3\u30fc\u30c9, \u53ce\u675f\u306b\u8981\u3057\u305f\u53cd\u5fa9\u56de\u6570\u3092\u8868\u3057\u307e\u3059.<\/p>\n<p>\u91cd\u6839 (1) \u306b\u3064\u3044\u3066\u306f\u7cbe\u5ea6\u304c\u534a\u5206\u7a0b\u5ea6\u306b\u843d\u3061\u3066\u3044\u308b\u306e\u304c\u308f\u304b\u308a\u307e\u3059. \u4ee3\u6570\u65b9\u7a0b\u5f0f\u306e\u6570\u5024\u8a08\u7b97\u306b\u304a\u3044\u3066\u306f, \\(m\\) \u91cd\u6839\u3092\u6c42\u3081\u308b\u5834\u5408\u306b\u89e3\u306e\u6709\u52b9\u6841\u6570\u304c\u304a\u304a\u3088\u305d \\(1\/m\\) \u306b\u306a\u308b\u306e\u3067\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059.<\/p>\n<h4>6.3.2 VBA\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f7f\u7528\u3057\u305f\u89e3\u304d\u65b9<\/h4>\n<p>\u4e0a\u3068\u540c\u3058\u4f8b\u984c\u3092 VBA \u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3088\u308a\u89e3\u304d\u307e\u3059. <strong>Rpzero2<\/strong> \u3092\u4f7f\u3063\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u4f8b\u3092\u793a\u3057\u307e\u3059.<\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism line-numbers lang-vb\" data-lang=\"VBA\"><code>Sub Start()\r\n    Const NMax = 10\r\n    Dim N As Long\r\n    Dim A(NMax) As Double, XR(NMax) As Double, XI(NMax) As Double, S(NMax) As Double\r\n    Dim IFlag As Long, Info As Long, Iter As Long, I As Long\r\n    '--- Input data\r\n    N = 5\r\n    For I = 0 To N\r\n        A(I) = Cells(5 + I, 1)\r\n    Next\r\n    '--- Compute roots of equation\r\n    IFlag = 0\r\n    Call Rpzero2(N, A(), XR(), XI(), IFlag, S(), Info, Iter)\r\n    Cells(10, 2) = Info\r\n    Cells(10, 3) = Iter\r\n    '--- Output roots\r\n    For I = 0 To N - 1\r\n        Cells(5 + I, 2) = XR(I)\r\n        Cells(5 + I, 3) = XI(I)\r\n        Cells(5 + I, 4) = S(I)\r\n    Next\r\nEnd Sub<\/code><\/pre>\n<\/div>\n<p>\u6240\u5b9a\u306e\u4f4d\u7f6e(\u4e0b\u306e\u30aa\u30ec\u30f3\u30b8\u8272\u306e\u30bb\u30eb)\u306b\u4fc2\u6570\u30c7\u30fc\u30bf\u3092\u5165\u529b\u3057, \u30de\u30af\u30ed Start \u3092\u5b9f\u884c\u3059\u308b\u3068\u6b21\u306e\u7d50\u679c\u304c\u5f97\u3089\u308c\u307e\u3059. \u30ef\u30fc\u30af\u30b7\u30fc\u30c8\u95a2\u6570\u3092\u4f7f\u7528\u3057\u305f\u3068\u304d\u3068\u7570\u306a\u308a, \u4fc2\u6570\u30c7\u30fc\u30bf\u3092\u5165\u529b\u3057\u305f\u3060\u3051\u3067\u306f\u7d50\u679c\u304c\u5f97\u3089\u308c\u305a, VBA \u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3057\u3066\u3084\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2015\/10\/Ex6_1.png\" alt=\"\" width=\"979\" height=\"786\" \nclass=\"aligncenter size-full wp-image-4178\" srcset=\"https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2015\/10\/Ex6_1.png 979w, https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2015\/10\/Ex6_1-300x241.png 300w, https:\/\/www.ktech.biz\/jp\/wp-content\/uploads\/sites\/2\/2015\/10\/Ex6_1-768x617.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9ad8\u6b21\u4ee3\u6570\u65b9\u7a0b\u5f0f\u306e\u89e3\u6cd5\u3068XLPack\u3092\u4f7f\u3063\u305f\u89e3\u304d\u65b9<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[10],"tags":[],"class_list":["post-4749","post","type-post","status-publish","format-standard","hentry","category-tutorial"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/posts\/4749","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/comments?post=4749"}],"version-history":[{"count":5,"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/posts\/4749\/revisions"}],"predecessor-version":[{"id":5122,"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/posts\/4749\/revisions\/5122"}],"wp:attachment":[{"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/media?parent=4749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/categories?post=4749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ktech.biz\/jp\/wp-json\/wp\/v2\/tags?post=4749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}