libnum:examples:gear
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| libnum:examples:gear [2026/03/29 13:45] – abc | libnum:examples:gear [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Integration of Systems of Linear Differential Equations. Gear's method ====== | ||
| - | |||
| - | Let's examine the following //SLDE//: | ||
| - | y₁′ = y₂ | ||
| - | y₂′ = y₁ | ||
| - | y₁(0)=0 | ||
| - | NB: we expect // | ||
| - | |||
| - | < | ||
| - | #include < | ||
| - | #include < | ||
| - | #include < | ||
| - | |||
| - | #include < | ||
| - | #include " | ||
| - | #include " | ||
| - | |||
| - | using namespace NumericMethods; | ||
| - | |||
| - | /* | ||
| - | y₁′ = y₂ | ||
| - | y₂′ = y₁ | ||
| - | y₁(0)=0 | ||
| - | // NB: we expect sin(x)/ | ||
| - | */ | ||
| - | |||
| - | static bool derfun(int n, double x, const double y[], double dy[]) | ||
| - | { | ||
| - | dy[0] = y[1]; | ||
| - | dy[1] = -y[0]; | ||
| - | return true; | ||
| - | } | ||
| - | |||
| - | static bool jacobian(int n, double x, const double y[], double j[]) | ||
| - | { | ||
| - | //for (int i = 0; i<n*n; ++i) j[i] = 0; | ||
| - | j[0] = 0; j[1] = 1; j[2] = -1; j[3] = 0; // sin/cos | ||
| - | return true; | ||
| - | } | ||
| - | |||
| - | |||
| - | void test_gear() | ||
| - | { | ||
| - | |||
| - | | ||
| - | | ||
| - | |||
| - | Gear solver; | ||
| - | | ||
| - | | ||
| - | | ||
| - | | ||
| - | |||
| - | // | ||
| - | /*1*/ GearPrintToStream print_1(std:: | ||
| - | |||
| - | /*2*/ std:: | ||
| - | | ||
| - | |||
| - | /*3*/ std:: | ||
| - | | ||
| - | |||
| - | | ||
| - | print_4.setFormat(" | ||
| - | |||
| - | | ||
| - | |||
| - | try | ||
| - | { | ||
| - | Message rc=solver.solve(0, | ||
| - | } | ||
| - | | ||
| - | { | ||
| - | | ||
| - | } | ||
| - | | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | ---- | ||
| - | [ [[..: | ||
libnum/examples/gear.1774781121.txt.gz · Last modified: by abc
