#ifndef RungeKutta_hpp\n#define RungeKutta_hpp\n#include <stdio.h>\nclass RungeKutta {\n float * result;\n int num;\n void calculateNextStep(float (*f[])(float t, float *x), float t0, float *x, float tn, int num);\npublic:\n RungeKutta(){};\n RungeKutta(float (*f[])(float t, float *x), float t0, float tn, float *x, int div, int num);\n float getValue(int step, int index);\n};\n#endif \/* RungeKutta_hpp *\/<\/code><\/pre><\/div>\n\n\n\n#include "RungeKutta.hpp"\nfloat RungeKutta::getValue(int step, int index){\n return result[step*num + index];\n}\nRungeKutta::RungeKutta(float (*f[])(float t, float *x), float t0, float tn, float *x, int div, int _num){\n num = _num;\n result = new float[div*num];\n float h = (tn - t0)\/div;\n for(int i=0; i<div; ++i){\n calculateNextStep(f, t0, x, t0+h, num);\n for(int j=0; j<num; ++j){\n result[i*num+j] = x[j];\n t0 += h;\n }\n }\n}\nvoid RungeKutta::calculateNextStep(float (*f[])(float t, float *x), float t0, float *x, float tn, int num){\n float k1[num], k2[num], k3[num], k4[num], tmp[num];\n float h = (tn - t0);\n float t = t0;\n for(int j=0; j<num; j++){\n k1[j] = (*f[j])(t, x);\n tmp[j] = x[j] + h*k1[j]\/2;\n k2[j] = (*f[j])(t+h\/2, tmp);\n tmp[j] = x[j] + h*k2[j]\/2;\n k3[j] = (*f[j])(t+h\/2, tmp);\n tmp[j] = x[j] + h*k3[j];\n k4[j] = (*f[j])(t+h, tmp);\n x[j] += (k1[j] + 2*k2[j] + 2*k3[j] + k4[j])*h\/6;\n }\n}<\/code><\/pre><\/div>\n\n\n\n <\/p>\n\n\n\n
<\/span>\u4f7f\u3044\u65b9<\/span><\/h2>\n\n\n\n\u6e1b\u8870\u632f\u52d5\u306e\u4ee5\u4e0b\u306e\u5f0f\u3092\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u4ee5\u4e0b\u306e\u3088\u3046\u306by\u3092\u5b9a\u7fa9\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u3059\u308b\u3068\u3001\u6e1b\u8870\u632f\u52d5\u306e\u65b9\u7a0b\u5f0f\u306f\u3053\u308c\u3092\u4ee3\u5165\u3059\u308b\u3053\u3068\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n
<\/p>\n\n\n\n
\u3053\u306e\u3088\u3046\u306b2\u3064\u306e\u4e00\u56de\u5fae\u5206\u65b9\u7a0b\u5f0f\u306b\u5206\u89e3\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n
\u3053\u306e\u4e8c\u3064\u306e\u95a2\u6570\u3092_f0<\/code>, _f1<\/code>\u3068\u3057\u3066\u5b9a\u7fa9\u3057\u3066\u3001Runge-Kutta\u306b\u304b\u3051\u307e\u3059\u3002<\/p>\n\n\n\n#define LOOP 10000\nfloat _f0(float t, float * x){\n return x[1];\n}\nfloat _f1(float t, float * x){\n return - x[0] - 0.2 * x[1];\n}\nfloat (*f[2])(float, float*);\nf[0] = _f0;\nf[1] = _f1;\nfloat initialValues[] = {30.0, 0.0};\nRungeKutta rk = RungeKutta(f, 0, 30, initialValues, LOOP, 2);\nfor(int i=0; i<LOOP; ++i){\n cout << rk.getValue(i, 0) << endl;\n}<\/code><\/pre><\/div>\n\n\n\n<\/span>\u89e3\u8aac<\/span><\/h2>\n\n\n\n\u5909\u6570\u540d\u304c\u5909\u308f\u3063\u3066\u3044\u308b\u306e\u3067\u5206\u304b\u308a\u306b\u304f\u3044\u3067\u3059\u304c\u3001_f0<\/code>, _f1<\/code>\u306e\u4e2d\u306ex[0]<\/code>\u304cx\u3001x[1]<\/code>\u304cy\u306b\u76f8\u7b49\u3057\u307e\u3059\u3002<\/p>\n\n\n\nRungeKutta\u30af\u30e9\u30b9\u306e\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u5f15\u6570\u306e\u610f\u5473\u3092\u4ee5\u4e0b\u306b\u307e\u3068\u3081\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n
- \u7b2c1\u5f15\u6570\u306f\u5fae\u5206\u65b9\u7a0b\u5f0f\u30921\u968e\u5fae\u5206\u65b9\u7a0b\u5f0f\u306b\u5206\u5272\u3057\u305f\u95a2\u6570\u7fa4<\/li>
- \u7b2c2,3\u5f15\u6570\u306f\u5b9a\u7fa9\u57df\u3092\u8868\u3057\u307e\u3059\u3002<\/li>
- \u7b2c4\u5f15\u6570\u306f\u5b9a\u7fa9\u57df\u3092\u3069\u306e\u304f\u3089\u3044\u5206\u5272\u3057\u3066\u8a08\u7b97\u3059\u308b\u304b\u3092\u8868\u3057\u307e\u3059\u3002<\/li>
- \u7b2c5\u5f15\u6570\u306f\u5fae\u5206\u65b9\u7a0b\u5f0f\u30921\u968e\u5fae\u5206\u65b9\u7a0b\u5f0f\u306b\u5206\u5272\u3057\u305f\u3068\u304d\u306e\u65b9\u7a0b\u5f0f\u306e\u500b\u6570\u3067\u3059\u3002<\/li><\/ul>\n\n\n\n
\u4eca\u56de\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u306f2\u3064\u306e\u521d\u671f\u4f4d\u7f6e30cm\u3001\u521d\u901f0cm\/s\u3068\u3057\u3066\u3044\u307e\u3059\u3002\u9023\u7acb\u5e38\u5fae\u5206\u65b9\u7a0b\u5f0f\u30920\u301c30\u79d2\u306e\u6642\u9593\u309210000\u5206\u5272(0.003\u79d2\u306e\u7c92\u5ea6)\u3067\u3001\u8a08\u7b97\u3059\u308b\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n
rk.getValue\u306e\u5f15\u6570\u306e\u610f\u5473\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n
- \u7b2c1\u5f15\u6570\u306f\u4f55\u756a\u76ee\u306e\u5024\u304b\uff1f<\/li>
- \u7b2c2\u5f15\u6570\u306f\u4f55\u756a\u76ee\u306e\u5909\u6570\u304b\uff1f<\/li><\/ul>\n\n\n\n
\u3092\u8868\u3057\u307e\u3059\u3002<\/p>\n\n\n\n
\u4eca\u56de\u306fx(x[0]<\/code>)\u306e\u5024\u304c\u6b32\u3057\u3044\u306e\u3067\u3001\u7b2c2\u5f15\u6570\u30920\u3068\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n\u3082\u3057\u3001\u7b2c2\u5f15\u6570\u30921\u306b\u3059\u308b\u3068\u3001y(x[1]<\/code>)\u306e\u5024\u304c\u53d6\u308c\u308b\u306e\u3067\u3001\u901f\u5ea6\u304c\u8a08\u7b97\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<\/span>\u7d50\u679c<\/span><\/h2>\n\n\n\nopenFrameworks\u3067\u30b0\u30e9\u30d5\u3092\u63cf\u753b\u3057\u3066\u3084\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n