//======================================================
// 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)
// Lotka - Volterra equation
//
import java.io.*;

class fm1 extends f_xi
{
 double func(double x[],int x_ref)
 {
   double k=1;
   double a=0;
	 if(x_ref==0) a= x[1];
   else if (x_ref==1) a= -k*Math.sin(x[0]);
   return a;
 }
}

class NA96A
{

public static void main(String args[]) throws IOException
{
  fm1 b1=new fm1();
  double y[];
  y=new double[2];
  y[0]=0.1;
  y[1]=0.2;
  double a[][]=NA93.RK6(b1,0.0,10.0,y,10000);
  Plot p1=new Plot(a[0],a[1]);
  p1.addData(a[0],a[2]);
  p1.setXlabel("time");
  p1.setYlabel("Predator and Prey population");
  p1.setPlabel("Predator-Prey model");
  p1.plot();
  
  Plot p2=new Plot(a[1],a[2]);
  p2.setXlabel("x");
  p2.setYlabel("y");
  p2.setPlabel("f(x)");
  p2.plot();
 }
}
