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


class fm1 extends f_xi
{
//multivariable function
 double func(double x[],int x_ref)
 {
   //x[0] is x, x[1] is y
   if(x_ref==0) return x[2];
   if(x_ref==1) return 10-10.0*x[1]-11*x[2];
   else return 0;
 }
}


class NA94D
{
public static void main(String args[]) throws IOException
  {
  fm1 b1=new fm1();
  double y[];
  y=new double[2];
  y[0]=0;
  y[1]=0; 
  double x0=0;
  double xn=1.0;
  double yn=0.5912968720769493 ;
   double A0[]=new double[10];
   double AN[]=new double[10];
   for(int i=0;i<10;i++)
   {
   A0[i]=-0.5+0.1*i;
   y[1]=A0[i];
   double a[][]=NA93.RK6(b1,x0,xn,y,2000);
   AN[i]=a[1][a[0].length-1];
   }
   double e[]=RK6A.PolynomialLSQ(AN,A0,3);
   y[1]=RK6A.funcPolynomialLSQ(e,yn);
   double a[][]=NA93.RK6(b1,x0,xn,y,2000); 
   Text.print(Text.T(a));
   Plot pp=new Plot(a);
   pp.plot();
 }
}
