//======================================================
// Numerical Analysis package in java
// example to show differential equation solution
// Runge-Kutta 6 method with multible differential equations
// Dr. Turhan Coban
// =====================================================
// dy1/dx=f(x,y1,y2,..,yn)
// dy2/dx=f(x,y1,y2,..,yn)
// ......
// dyn/dx=f(x,y1,y2,..,yn)
// Pendulum problem

import java.io.*;

class fm1 extends f_xi
{

 double func(double x[],int x_ref)
 {
   //  Mathieu Equation
   //  d2x/dt2+(d+2e*cos(2t))x=0
   double delta=8;
   double epsilon=2.5;
   double a=0;
   if(x_ref==1) a= -(delta+2*epsilon*Math.cos(2.0*x[0]))*x[1];
   else if(x_ref==0) a= x[2];
   return a;
 }
}

class NA101D
{

public static void main(String args[]) throws IOException
{
fm1 b3=new fm1();
  double y[]=new double[2];
  y[0]=1.0;
  y[1]=0.0; 
  //solution of the differential system : 
  double xi[]=new double[20];
  double fi[]=new double[20];
  double a[][];
  a=NA93.RK6(b3,0.0,100.0,y,1000000);
  Text.print(Text.T(a));
  Plot pp=new Plot(a[0],a[1]);
  pp.setXlabel("t time s");
  pp.setYlabel("x");
  pp.setPlabel("Mathieu equation ");
  pp.plot();
 }
}
