連立微分方程式 を与えられた初期値のもとで解きます。
を初期値,として解きます。
#include <iostream> #include <octave/config.h> #include <octave/Matrix.h> #include <octave/LSODE.h> using namespace std; ColumnVector xdot(const ColumnVector& x, double t) { ColumnVector dx(2); dx(0) = x(0) + 2*x(1); dx(1) = -4*x(0) - 3*x(1); return dx; } int main() { ColumnVector xi(2), x(2); ODEFunc odef(xdot); // set xdot xi(0)=0.0; // initial condition xi(1)=1.0; // LSODE ls(xi,0.0,odef); // solver for(double t = 0; t <= 3.0; t+=0.1) { x=ls.do_integrate(t); cout << t << " " << x(0) << " " << x(1) << endl; } }
0 0 1 0.1 0.179763 0.707037 0.2 0.318829 0.435272 0.3 0.418297 0.193126 0.4 0.480858 -0.0138417 0.5 0.510378 -0.182668 0.6 0.511514 -0.312648 (・・・中略・・・) 2.7 -0.0519342 0.0945891 2.8 -0.0383875 0.0855498 2.9 -0.0255641 0.0742883
解は, となります。
管理人? (2005-01-05 (水) 16:42:53)
単純にColumnVectorをComplexColumnVectorにしただけでは駄目らしい。
複素数も扱えるソルバーは何?
管理人? (2005-01-05 (水) 16:39:47)
私の環境(Windows,Cygwinにoctave-2.1.64をインストール)では、コンパイル時に/usr/local/include/octave-2.1.64/octave/LSODE.h:34:24:\ LSODE-opts.h: No such file or directoryと出てコンパイルできませんでした。コンパイルのオプションとして
-I/usr/local/include/octave-2.1.64/octaveと付け加えることでコンパイルできました。
&ref(): File not found: "wikilogo1.png" at page "連立微分方程式を解きたい"; |