We present a program to solve by a numerical scheme a system of
first-order linear differential equations of the form
A1y' + A0y = f
where the matrices A0 and A1 are
| 0 -1 | | 1 0 | | 0 |
A0 = | |, A1 = | |, f = | |
| 1 -1 | | 0 1 | | 3(t-1)exp(t) |
With adapted initial conditions, the solution is given by
y1(t) = t*exp(-t), y2(t) = (1-t)*exp(-t)
- After initializing the global variables theFinalTime and theTimeStep, we declare an instance of class
ODESolver,
where we have chosen the BDF2 scheme (2nd order Backward Difference
Formula), and set the number of equations to 2.
ODESolver ode(BDF2,theTimeStep,theFinalTime,2);
|