libnum:examples:gear
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| libnum:examples:gear [2026/03/04 13:52] – created abc | libnum:examples:gear [2026/03/29 13:46] (current) – abc | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Integration of Systems of Linear Differential Equations ====== | + | ====== Integration of Systems of Linear Differential Equations. Gear's method |
| - | Gear Method.\\ | + | |
| Let's examine the following //SLDE//: | Let's examine the following //SLDE//: | ||
| - | | + | |
| - | + | | |
| + | y₁(0)=0 | ||
| + | NB: we expect // | ||
| < | < | ||
| - | #include <stdio.h> | + | #include <iostream> |
| + | #include < | ||
| + | #include < | ||
| #include < | #include < | ||
| #include " | #include " | ||
| + | #include " | ||
| using namespace NumericMethods; | 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; | ||
| + | } | ||
| + | |||
| + | |||
| + | int main() | ||
| + | { | ||
| + | |||
| + | | ||
| + | | ||
| + | |||
| + | Gear solver; | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | // | ||
| + | /*1*/ GearPrintToStream print_1(std:: | ||
| + | |||
| + | /*2*/ std:: | ||
| + | | ||
| + | |||
| + | /*3*/ std:: | ||
| + | | ||
| + | |||
| + | | ||
| + | print_4.setFormat(" | ||
| + | |||
| + | | ||
| + | |||
| + | try | ||
| + | { | ||
| + | Message rc=solver.solve(0, | ||
| + | } | ||
| + | | ||
| + | { | ||
| + | | ||
| + | } | ||
| + | | ||
| + | } | ||
| </ | </ | ||
| + | |||
| + | ---- | ||
| + | [ [[..: | ||
| + | |||
libnum/examples/gear.1772621565.txt.gz · Last modified: by abc
