ファン・デア・ポル方程式をオイラー法で解くプログラム
#include <iostream>
using namespace std;
void euler(double&,double&,double,double);
int main(){
double x, v, f, h, t, tend;
int step;
x = 1.0;
v = 0.0;
f = 0;
tend = 100;
h = 0.1;
step = (int)(tend/h);
cout << t << " " << x << " " << v << endl;
for (int i = 0; i < step; i++){
euler(x,v,f,h);
t += h;
cout << t << " " << x << " " << v << endl;
}
}
void euler(double &x, double &v, double f, double h){
double dx, dv;
dx = v;
dv = -f*v*(x*x - 1) - x;
x = x + h*dx;
v = v + h*dv;
}

をfとしている。

の場合、緑線は厳密解

の場合

の場合
最終更新:2008年07月15日 15:41