//======================================================
// Numerical Analysis package in java
// example to show differential equation solution
// and differentiation (derivative) functions
// Dr. Turhan Coban
// =====================================================
import java.io.*;
import Numeric;
import complex;
import Matrix;


class fm1 extends f_xi
{
//multivariable function
 double func(double x[],int x_ref)
 {
   //x[0] is x, x[1] is y
   //this is a representation of equation : dy/dx=y
   //solution of this equation is e(x)
   if(x_ref==0) return -2*x[2]-4.0*x[1];
   if(x_ref==1) return x[2];
   else return 0;
 }
}


class dif7
{
  public static void main(String args[]) throws IOException
  {

  fm1 b3=new fm1();
  double x[];
  x=new double[2];
  x[0]=0;
  x[1]=2.0;
  //RK5 differential equation to solve differential equation  dy/dx=y
  //with limits 0 to 1 exact solution is e=2.7182818
  //boundary condition x=0 y=1 is given
  //final value x=1 to be calculated by the method
  System.out.println(Matrix.toString(Matrix.T(Numeric.RK6(b3,0.0,5.0,x,50))));
 }
}
