{"id":222,"date":"2017-08-19T16:36:50","date_gmt":"2017-08-19T07:36:50","guid":{"rendered":"http:\/\/daily-memorials.net\/?p=222"},"modified":"2017-09-11T21:35:28","modified_gmt":"2017-09-11T12:35:28","slug":"%e6%95%b0%e5%80%a4%e8%a8%88%e7%ae%97%e3%81%be%e3%81%a8%e3%82%812-rk2","status":"publish","type":"post","link":"http:\/\/daily-memorials.net\/?p=222","title":{"rendered":"\u6570\u5024\u8a08\u7b97(2) \u30eb\u30f3\u30b2\u30af\u30c3\u30bf\u6cd5"},"content":{"rendered":"<p><br \/>\n\u30aa\u30a4\u30e9\u30fc\u6cd5\u306f\u4e00\u6b21\u8fd1\u4f3c\u3092\u7528\u3044\u305f\u3082\u306e\u3067\u3042\u3063\u305f\u304c\u3001\u4e00\u6b21\u8fd1\u4f3c\u3067\u306f\u8a08\u7b97\u91cf\u306b\u5bfe\u3059\u308b\u8aa4\u5dee\u306e\u5024\u304c\u5927\u304d\u3059\u304e\u308b\u305f\u3081\u3001\u3088\u308a\u7cbe\u5ea6\u306e\u9ad8\u3044\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304c\u6c42\u3081\u3089\u308c\u308b\u3002<br \/>\n\u4e00\u822c\u7684\u306b\u3088\u304f\u7528\u3044\u3089\u308c\u308b\u65b9\u6cd5\u306f4\u6b21\u306e\u30eb\u30f3\u30b2\u30af\u30c3\u30bf\u6cd5(RK4)\u3060\u304c\u3001\u3053\u3053\u3067\u306f\u4e00\u6bb5\u968e\u7c21\u660e\u306a\uff12\u6b21\u306e\u30eb\u30f3\u30b2\u30af\u30c3\u30bf\u6cd5(RK2\uff09\u3092\u8003\u5bdf\u3057\u3066\u307f\u3088\u3046\u3002RK2\u304c\u308f\u304b\u308c\u3070RK4\u306f\u305d\u306e\u5fdc\u7528\u306a\u306e\u3067\u3001\u8a08\u7b97\u306f\u3084\u3084\u3053\u3057\u3044\u3082\u306e\u306e\u4ed5\u7d44\u307f\u306f\u7406\u89e3\u3067\u304d\u308b\u306f\u305a\u3067\u3042\u308b\u3002<br \/>\n\u524d\u56de\u3068\u540c\u3058\u3088\u3046\u306b\u4ee5\u4e0b\u306e\u5fae\u5206\u65b9\u7a0b\u5f0f\u306b\u3064\u3044\u3066\u8003\u5bdf\u3057\u3088\u3046<br \/>\n\\begin{equation}<br \/>\n\\frac{dy}{dx}= f(x,y)<br \/>\n\\end{equation}<\/p>\n<p>\u307e\u305a\u30aa\u30a4\u30e9\u30fc\u6cd5\u3067\u306f\u4e00\u30b9\u30c6\u30c3\u30d7\u306e\u8a08\u7b97\u8aa4\u5dee\u306e\u30aa\u30fc\u30c0\u30fc\u306f\\(o(x^2)\\)\u3067\u3042\u3063\u305f\u3002<br \/>\n\\[<br \/>\ny(x_0+h) = y(x_0) + h y'(x_0) + o(x^2)<br \/>\n\\]<br \/>\n\u66f4\u306b\u30aa\u30fc\u30c0\u30fc\u3092\u5fae\u5c0f\u306b\u3059\u308b\u306b\u306f\u30c6\u30fc\u30e9\u30fc\u5c55\u958b\u3092\uff12\u6b21\u306e\u9805\u307e\u3067\u8a08\u7b97\u3059\u308c\u3070\u3088\u3044\u3002<br \/>\n\\[<br \/>\ny(x_0+h) = y(x_0) + h y'(x_0) + \\frac{1}{2} h^2 y&#8221;(x_0) + o(x^3)<br \/>\n\\]<br \/>\n\u3055\u3066\u3001\u30aa\u30a4\u30e9\u30fc\u6cd5\u3067\u306f\\(y'(x) = f(x,y)\\)\u3092\u4ee3\u5165\u3057\u3066<br \/>\n\\[<br \/>\ny(x_0+h) = y(x_0) + h \\cdot f(x_0,y_0) + o(x^2)<br \/>\n\\]<br \/>\n\u3068\u3059\u308b\u3060\u3051\u3067\u826f\u304b\u3063\u305f\u304c\u3001RK2\u3067\u306f<br \/>\n\\[<br \/>\ny(x_0+h) = y(x_0) + h f(x_0,y_0) + \\frac{1}{2} h^2 f'(x_0,y_0) + o(x^3) \\tag{1}<br \/>\n\\]<br \/>\n\u3068\u3057\u305f\u3042\u3068\u3001\\(f'(x_0,y_0)\\)\u3092\u51e6\u7406\u3057\u306a\u3051\u308c\u3070\u306a\u3089\u306a\u3044<br \/>\n\u3053\u3053\u3067\\(f(x,y)=y\\)\u3068\u4eee\u5b9a\u3057\u3066\u307f\u308b\u3068\\(f'(x,y)=\\frac{dy}{dx} =f(x,y) = y\\)\u3067\u3042\u308b\u304b\u3089<\/p>\n<p>\\begin{align*}<br \/>\n&amp;y(x_{n+1}) = y(x_n) + h f(x_n,y_n) + \\frac{1}{2} h^2 f'(x_n,y_n) \\\\<br \/>\n&amp;= y(x_n) + h y_n+ \\frac{1}{2} h^2 y_n\u3000\\tag{2}<br \/>\n\\end{align*}<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u5c0e\u95a2\u6570\u304c\u3042\u3089\u304b\u3058\u3081\u308f\u304b\u3063\u3066\u3044\u308b\u306a\u3089\u6f38\u5316\u5f0f\u3092\u5bb9\u6613\u306b\u5c0e\u51fa\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u305f\u3002<br \/>\n\u3057\u304b\u3057\u3001\u4efb\u610f\u306e\\(f(x,y)\\)\u306b\u5bfe\u3059\u308b\u5c0e\u95a2\u6570\u3092\u6c42\u3081\u3066\u6f38\u5316\u5f0f\u3092\u5c0e\u51fa\u3059\u308b\u3053\u3068\u306f\u96e3\u3057\u3044\u3002\u305d\u3053\u3067\u3001\u5225\u306e\u30a2\u30d7\u30ed\u30fc\u30c1\u3092\u53d6\u308b\u3053\u3068\u306b\u306a\u308b\u3002<br \/>\n\u307e\u305a\u95a2\u6570\\(f(x,y)\\)\u306e\\(x,y\\)\u306b\u3064\u3044\u3066\u306e\u5168\u5fae\u5206\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b<br \/>\n\\[<br \/>\ndf = \\frac{\\partial f}{\\partial x} dx + \\frac{\\partial f}{\\partial y} dy \\tag{3}<br \/>\n\\]<br \/>\n(3)\u306e\u4e21\u8fba\u3092\\(dx\\)\u3067\u5272\u308b\u3068<br \/>\n\\begin{align*}<br \/>\nf'(x,y) = \\frac{df}{dx} = \\frac{\\partial f}{\\partial x} + \\frac{\\partial f}{\\partial y} \\cdot \\frac{dy}{dx} = f_x + f_y \\cdot f<br \/>\n\\end{align*}<\/p>\n<p>\u3068\u306a\u308a\u3001\u3053\u308c\u3092(1)\u306b\u4ee3\u5165\u3059\u308b\u3068<br \/>\n\\begin{align*}<br \/>\n&amp;y(x_0+h) = y(x_0) + h f(x_0,y_0) \\\\<br \/>\n&amp;+ \\frac{1}{2} h^2 (f_x(x_0,y_0) + f_y(x_0,y_0) \\cdot f(x_0,y_0)) +o(x^3)\u00a0\\tag{4}<br \/>\n\\end{align*}<br \/>\n\u3068\u306a\u308b\u3002<br \/>\n\\(f_x(x_0,y_0),f_y(x_0,y_0)\\)\u306f\\(f(x_0,y_0)\\)\u306e\u8fd1\u508d\u3067\u591a\u5909\u6570\u306e\u30c6\u30fc\u30e9\u30fc\u5c55\u958b\u3092\u884c\u3046\u3053\u3068\u3067\u751f\u6210\u3055\u308c\u308b\u8fd1\u4f3c\u5f0f\u306b\u542b\u307e\u308c\u308b\u3002<br \/>\n\u305d\u3053\u3067\\(k_1 = f(x_0,y_0)\\), \\(k_2 = f(x_0+ah,y_0+b h k_1)\\)\u3068\u304a\u304d\u3001\\(k_2\\)\u3092\\(f(x_0,y_0)\\)\u306e\u8fd1\u508d\u3067\u30c6\u30fc\u30e9\u30fc\u5c55\u958b\u3057\u3066\u307f\u3088\u3046\u3002<br \/>\n\\[ \\begin{align*}<br \/>\nk_2 &amp;= f(x_0+ah,y_0+b h k_1) \\\\<br \/>\n&amp;= f(x_0,y_0) + ahf_x(x_0,y_0) +bh k_1 f_y(x_0,y_0) + o(h^2)<br \/>\n\\end{align*}\\]<br \/>\n\u3053\u3053\u3067\\(k_1\\)\u3068\\(k_2\\)\u306b\u91cd\u307f\\(w_1\\),\\(w_2\\)\u3092\u304b\u3051\u305f\u7dda\u5f62\u548c\\(\\phi =w_1 k_1 + w_2 k_2\\)\u3092\u3068\u308b\u3002<br \/>\n\\[<br \/>\ny(x_0+h) = y(x_0) + h \\phi<br \/>\n\\]<br \/>\n\u3053\u306e\u5f0f\u3092\u5c55\u958b\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u3001(4)\u3068\u6052\u7b49\u3067\u3042\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002<br \/>\n\\begin{align*}<br \/>\n&amp;y(x_0+h) = y(x_0) + h(w_1+w_2)f(x_0,y_0) \\\\<br \/>\n&amp;+h^2 w_2\\bigl( a f_x(x_0,y_0)+ b f_y(x_0,y_0) \\cdot f(x_0,y_0)\\bigr) + o(h^3) \\tag{5}<br \/>\n\\end{align*}<br \/>\n(4)\u3001(5)\u306e\u4fc2\u6570\u3092\u6bd4\u8f03\u3059\u308b\u3053\u3068\u3067\\(w_1 +w_2 = 1\\)\u3001\\(w_2a = w_2b = 0.5\\)\u304c\u5c0e\u304b\u308c\u3001<br \/>\n\\(w_1,w_2,a,b\\)\u306e\u5024\u3092\u4e0a\u5f0f\u306b\u9069\u5408\u3059\u308b\u7bc4\u56f2\u5185\u3067\u4efb\u610f\u306b\u6c7a\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u3053\u3053\u3067\u306f<br \/>\n\\(w_1 =0, w_2 = 1, a = \\frac{1}{2},b = \\frac{1}{2}\\)\u3068\u3059\u308b\u3002(\u5225\u540d:\u4fee\u6b63\u30aa\u30a4\u30e9\u30fc\u6cd5)<br \/>\n\u6c7a\u5b9a\u3057\u305f\u4fc2\u6570\u3092\u5f53\u3066\u306f\u3081\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<br \/>\n\\[<br \/>\ny(x_0+h) = y(x_0) + h f\\bigl(x_0 +\\frac{1}{2} h,y_0+\\frac{1}{2}h f(x_0,y_0)\\bigr)\\tag{6} \\\\<br \/>\n\\]<br \/>\n\u3055\u3066\u3001\u3053\u3053\u307e\u3067\u304cRK2\u306e\u8aac\u660e\u3067\u3042\u308b\u3002\u3053\u3053\u304b\u3089\u306fRK2\u3092\u5b9f\u969b\u306b\u7528\u3044\u3066\u8a08\u7b97\u3092\u3055\u305b\u3066\u307f\u3088\u3046\u3002\u524d\u56de\u306f\\(f(x,y) = y\\)<br \/>\n\u3068\u3044\u3046\u5f0f\u3092\u7528\u3044\u305f\u304c\u3001\u7cbe\u5ea6\u304c\u5411\u4e0a\u3057\u305f\u3053\u3068\u3092\u78ba\u304b\u3081\u308b\u610f\u5473\u3067\u3082\u540c\u3058\u5f0f\u3092\u63a1\u7528\u3057\u3088\u3046\u3002<br \/>\n(6),(7)\u3088\u308a<br \/>\n\\begin{align*}<br \/>\n&amp;y(x_{n+1}) = y(x_n) + h f\\bigl(x_n +\\frac{1}{2} h,y_n+\\frac{1}{2}h f(x_n,y_n)\\bigr) \\\\<br \/>\n&amp;= y(x_n) + h\\cdot \\bigl(y_n + \\frac{1}{2}h f(x_n,y_n)\\bigr) \\\\<br \/>\n&amp;= y(x_n) + hy(x_n)+ \\frac{1}{2} h^2 y(x_n) \\tag{8}<br \/>\n\\end{align*}<br \/>\n\u5f0f(8)\u306f\u5148\u307b\u3069\u6c42\u3081\u305f\u5f0f(2)\u3068\u540c\u3058\u3082\u306e\u3067\u3042\u308b\u3002<br \/>\n\u3053\u308c\u3092\u7528\u3044\u3066h=0.01\u306e\u523b\u307f\u5e45\u3067\\(y(10) = e^{10}\\)\u3092\u6c42\u3081\u305f\u3068\u3053\u308d\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u305f\u3002<br \/>\n\\(e^{10} = 22026.465795\\)<br \/>\n\u30aa\u30a4\u30e9\u30fc\u6cd5 \\(y(10)=20959.155638\\) \u8aa4\u5dee\\(e = 1067.310157\\)<br \/>\nRK2 \\(y(10)=22022.822441\\) \u8aa4\u5dee\\(e= 3.643353\\)<br \/>\n\u3053\u306e\u3053\u3068\u304b\u3089\u540c\u4e00\u30b9\u30c6\u30c3\u30d7\u6570\u3067\u3082\u304b\u306a\u308a\u8aa4\u5dee\u304c\u5c0f\u3055\u304f\u306a\u3063\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308b\u3002<br \/>\n\uff14\u6b21\u306e\u30eb\u30f3\u30b2\u30af\u30c3\u30bf\u6cd5\u306f\u8a3c\u660e\u304c\u66f4\u306b\u96e3\u89e3\u306b\u306a\u308b\u304c\u3001\u8a08\u7b97\u306b\u7528\u3044\u308b\u3053\u3068\u81ea\u4f53\u306f\u5bb9\u6613\u306a\u306e\u3067\u3001\u5fae\u5206\u65b9\u7a0b\u5f0f\u306e\u8a08\u7b97\u3092\u3059\u308b\u3068\u304d\u306b\u306f\u305d\u3061\u3089\u3092\u4f7f\u3046\u306e\u304c\u671b\u307e\u3057\u3044\u3060\u308d\u3046\u3002<br \/>\n\u3061\u306a\u307f\u306b4\u6b21\u306e\u30eb\u30f3\u30b2\u30af\u30c3\u30bf\u6cd5\u3092\u7528\u3044\u305f\u6642\u306e\\(y(10) = e^{10}\\)\u306e\u5024\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<br \/>\nRK4 \\(y(10)=22026.465777\\) \u8aa4\u5dee \\(e =0.000018\\)<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;math.h&gt;\r\nint main(int argc, const char * argv[]) {\r\n    \/\/ insert code here...\r\n    printf(&quot;Hello, World!\\n&quot;);\r\n    double y[2001];\r\n    double k[4];\r\n    double x;\r\n    scanf(&quot;%lf&quot;,&amp;amp;x);\r\n    double h = 0.01;\r\n    int count = x\/h;\r\n    printf(&quot;count=%d\\n&quot;,count);\r\n    y[0] = 1.0f;\r\n    \/\/\u30aa\u30a4\u30e9\u30fc\u6cd5\r\n    for(int i=0;i&lt;count;i++){\r\n        y[i+1] = y[i] + h*y[i];\r\n        \r\n    }\r\n    printf(&quot;y=%f exp=%f dif = %f\\n&quot;\r\n,y[count],exp(x),fabs(y[count]-exp(x)));\r\n    \r\n    \/\/RK2\r\n    for(int i=0;i&lt;count;i++){\r\n        y[i+1] = y[i] +  h * (y[i]*(1+0.5*h));\r\n    }\r\n    printf(&quot;y=%f exp=%f dif=%f\\n&quot;\r\n,y[count],exp(x),fabs(y[count]-exp(x)));\r\n   \r\n    \/\/RK4\r\n    for(int i=0;i&lt;count;i++){\r\n        k[0] = h*y[i];\r\n        k[1] = h*(y[i]+k[0]\/2);\r\n        k[2] = h*(y[i]+k[1]\/2);\r\n        k[3] = h*(y[i]+k[2]);\r\n        y[i+1] = y[i] + ( k[0] + 2*k[1] + 2*k[2] + k[3])\/6;\r\n    }\r\n    printf(&quot;y=%f exp=%f dif=%f\\n&quot;\r\n,y[count],exp(x),fabs(y[count]-exp(x)));\r\n    return 0;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u30aa\u30a4\u30e9\u30fc\u6cd5\u306f\u4e00\u6b21\u8fd1\u4f3c\u3092\u7528\u3044\u305f\u3082\u306e\u3067\u3042\u3063\u305f\u304c\u3001\u4e00\u6b21\u8fd1\u4f3c\u3067\u306f\u8a08\u7b97\u91cf\u306b\u5bfe\u3059\u308b\u8aa4\u5dee\u306e\u5024\u304c\u5927\u304d\u3059\u304e\u308b\u305f\u3081\u3001\u3088\u308a\u7cbe\u5ea6\u306e\u9ad8\u3044\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304c\u6c42\u3081\u3089\u308c\u308b\u3002 \u4e00\u822c\u7684\u306b\u3088\u304f\u7528\u3044\u3089\u308c\u308b\u65b9\u6cd5\u306f4\u6b21\u306e\u30eb\u30f3\u30b2\u30af\u30c3\u30bf\u6cd5(RK4)\u3060\u304c\u3001\u3053\u3053\u3067\u306f\u4e00\u6bb5\u968e\u7c21\u660e &hellip; <a href=\"http:\/\/daily-memorials.net\/?p=222\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u6570\u5024\u8a08\u7b97(2) \u30eb\u30f3\u30b2\u30af\u30c3\u30bf\u6cd5&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":322,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"http:\/\/daily-memorials.net\/index.php?rest_route=\/wp\/v2\/posts\/222"}],"collection":[{"href":"http:\/\/daily-memorials.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/daily-memorials.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/daily-memorials.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/daily-memorials.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=222"}],"version-history":[{"count":50,"href":"http:\/\/daily-memorials.net\/index.php?rest_route=\/wp\/v2\/posts\/222\/revisions"}],"predecessor-version":[{"id":607,"href":"http:\/\/daily-memorials.net\/index.php?rest_route=\/wp\/v2\/posts\/222\/revisions\/607"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/daily-memorials.net\/index.php?rest_route=\/wp\/v2\/media\/322"}],"wp:attachment":[{"href":"http:\/\/daily-memorials.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=222"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/daily-memorials.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=222"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/daily-memorials.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=222"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}