computations
In the following examples we show how to use CAPD to integrate ODE along with variational equations to obtain not only image of a set but also normalized derivatives up to given order r with respect to initial conditions.
In general classes that we use have ICn prefix, which means that they rigorously (I) compute and store derivatives to given order (Cn).
Integration of ODE
We integrate a harmonic oscilator for a half of period with fixed time step. So we expect fist derivative to be and the other derivatives to be equal 0.
We need to include only one file
IMap f(
"var:x,y;fun:-y,x;",degree);
int numberOfSteps = 128;
double timeStep =
PI/numberOfSteps;
solver.setStep(timeStep);
double radius = 0.1;
for(int i=0; i<numberOfSteps; ++i){
set.move(solver);
}
std::cout << "\n initial condition : " << v
<< "\n time of integration : " << numberOfSteps*timeStep
<<
"\n value : \n " <<
IVector(set)
<<
"\n C^1 derivative :\n" <<
IMatrix(set)
<< "\n all derivatives" << set.currentSet().toString();
This class is used to represent a map .
Definition: Map.h:125
const double PI
Definition: cndemo1.cpp:22
capd::dynset::CnDoubletonSet< capd::IMatrix, C2Rect2Policies > CnMultiMatrixRect2Set
Definition: typedefs.h:66
int order
Definition: tayltst.cpp:31
capd::vectalg::Vector< capd::DInterval, CAPD_DEFAULT_DIMENSION > IVector
Definition: typedefs.h:33
capd::dynsys::CnOdeSolver< capd::IMap > ICnOdeSolver
Definition: typedefs.h:21
intervals::DoubleInterval interval
Definition: DoubleInterval.h:36
capd::vectalg::Matrix< capd::DInterval, CAPD_DEFAULT_DIMENSION, CAPD_DEFAULT_DIMENSION > IMatrix
Definition: typedefs.h:34
The next example shows how to compute higher order derivatives with respect to initial condition with automatic step control along the trajectory.
Integration of ODE with automatic time step control (TSC)
In this example we changed the ODE and initial condition but in fact the only important difference is that instead of moving set "manually" we will use TimeMap class with automatic Time Step Control (TSC).
TimeMap class provides methods for transport of sets (or points) by a given flow over some time inter...
Definition: TimeMap.h:34
This class computes image of a given set after a given time.
Full source of this example
#include <iostream>
const int degree = 3;
std::cout << "\n Michelson equation \n----------------------\n";
IMap f(
"par:c;var:x,y,z;fun:y,z,c^2-y-0.5*x*x;",degree);
double sizeOfSet = 0.005;
v[0]=0.0; v[1]=
interval(1.563-sizeOfSet, 1.563+sizeOfSet); v[2]=0.0;
timeMap(time, set);
cout << set.currentSet().toString();
return 0;
}
Set that stores all derivatives to given order in doubleton form with reorganization moved by QR deco...
Definition: CnRect2Set.h:29
Definition: CnOdeSolver.h:42
Definition of template class Interval.
Definition: Interval.h:83
int main()
Definition: cndemo2.cpp:22
Definition: ApplicationDesc.h:23
How to compute derivatives of order bigger than 3?
We need to specify the maximal degre of the vector field IMap in the last argument of the contructor.
const int degree = 5;
std::cout << "\n Michelson equation \n----------------------\n";
IMap f(
"par:c;var:x,y,z;fun:y,z,1-y-0.5*x*x;", degree);
Now we can use our types instead of built-in and the rest remains the same:
#include <iostream>
const int degree = 5;
std::cout << "\n Michelson equation \n----------------------\n";
IMap f(
"par:c;var:x,y,z;fun:y,z,1-y-0.5*x*x;", degree);
double sizeOfSet = 0.005;
v[0]=0.0; v[1]=
interval(1.563-sizeOfSet, 1.563+sizeOfSet); v[2]=0.0;
timeMap(time, set);
cout << set.currentSet().toString();
return 0;
}
This set stores vector of derivatives with respect to a multiindex alpha as a doubleton.
Definition: CnDoubletonSet.h:33
int main()
Definition: cndemo3.cpp:21