The sources of the following examples can be found in the examples/encloseTrajectory
directory of the CAPD package.
Enclosure for a trajectory between time steps
#include "capd/capdlib.h"
using namespace std;
{
try{
cout.precision(12);
IMap vectorField(
"par:mu,mj;var:x,y,dx,dy;fun:dx,dy,x-mj*(x+mu)*sqrt((x+mu)^2+y^2)^(-3)-mu*(x-mj)*sqrt((x-mj)^2+y^2)^(-3)+2*dy,y*(1-mj*sqrt((x+mu)^2+y^2)^(-3)-mu*sqrt((x-mj)^2+y^2)^(-3))-2*dx;");
vectorField.setParameter("mu",mu);
vectorField.setParameter("mj",mj);
x[0]=0.9928634178;
x[1]=0.0;
x[2]=0.0;
x[3]=2.129213043;
double T=5;
timeMap.stopAfterStep(true);
do
{
timeMap(T,s);
cout << "\nstep made: " << stepMade;
int grid=2;
for(int i=0;i<grid;++i)
{
std::cout << "\nenclosure for t=" << prevTime + subsetOfDomain << ": " << v;
std::cout <<
"\ndiam(enclosure): " <<
diam(v);
}
prevTime = timeMap.getCurrentTime();
cout << "\ncurrent time: " << prevTime << endl << endl;
}while(!timeMap.completed());
}catch(exception& e)
{
cout << "\n\nException caught!\n" << e.what() << endl << endl;
}
}
Enclosure for derivatives (monodromy matrix) between time steps
#include "capd/capdlib.h"
using namespace std;
{
try{
cout.precision(12);
IMap vectorField(
"par:mu,mj;var:x,y,dx,dy;fun:dx,dy,x-mj*(x+mu)*sqrt((x+mu)^2+y^2)^(-3)-mu*(x-mj)*sqrt((x-mj)^2+y^2)^(-3)+2*dy,y*(1-mj*sqrt((x+mu)^2+y^2)^(-3)-mu*sqrt((x-mj)^2+y^2)^(-3))-2*dx;");
vectorField.setParameter("mu",mu);
vectorField.setParameter("mj",mj);
x[0]=0.9928634178;
x[1]=0.0;
x[2]=0.0;
x[3]=2.129213043;
double T=1;
timeMap.stopAfterStep(true);
solver.setAbsoluteTolerance(1e-12);
solver.setRelativeTolerance(1e-12);
do
{
timeMap(T,s);
cout << "\nstep made: " << stepMade;
int grid=10;
for(int i=0;i<grid;++i)
{
std::cout << "\nenclosure for t=" << prevTime + subsetOfDomain << ": " << v;
std::cout <<
"\ndiam(enclosure): " <<
diam(v);
std::cout << "\nenclosure of monodromy matrix for t=" << prevTime + subsetOfDomain << ": " << M;
std::cout <<
"\ndiam(enclosure of monodromy matrix): " <<
diam(M);
}
prevTime = timeMap.getCurrentTime();
cout << "\ncurrent time: " << prevTime << endl << endl;
}while(!timeMap.completed());
}catch(exception& e)
{
cout << "\n\nException caught!\n" << e.what() << endl << endl;
}
}