import java.io.*;
//import Numeric;
//import complex;

class f1 extends f_x
{
  double func(double x)
  {
  return x*x*Math.cos(x);
  }
}

class f2 extends f_x
{
  double func(double x)
  {
  return x*x*x;
  }
}

class fm1 extends f_xi
{
//multivariable function
 double func(double x[],int x_ref)
 {
   double a=0;
     switch(x_ref)
     {
     case 0: a=(x[0]+x[1]*x[1]+x[2]*2);break;
     case 1: a=(x[0]*3+x[1]*x[1]*x[1]+x[2]);break;
     case 2: a=(x[0]-5*x[1]*x[1]+x[2]*x[2]*x[2]);break;
     }
   return a;
 }
}

class fm2 extends fi_xi
{
//multivariable function
 double[] func(double x[])
 {
    double a[];
    a=new double[3];
    a[0]=(x[0]+x[1]*x[1]+x[2]*2);
    a[1]=(x[0]*3+x[1]*x[1]*x[1]+x[2]);
    a[2]=(x[0]-5*x[1]*x[1]+x[2]*x[2]*x[2]);
   return a;
 }
}

class integ1
{
  public static void main(String args[]) throws IOException
  {
  f1 b1;
  b1=new f1();
  f2 b2;
  b2=new f2();
  fm1 b3;
  b3=new fm1();
  double x[];
  fm2 b4;
  b4=new fm2();
  x=new double[3];
  x[0]=1;
  x[1]=2;
  x[2]=3;
  System.out.println("*********integral of class   f1 : "+Numeric.integral(b1,0.0,(Math.PI/2.0)));
  System.out.println("integral of class   f2 : "+Numeric.integral(b2,0.0,1.0));
  System.out.println("Derivative of class f1 : "+Numeric.derivative(b1,1.0));
  System.out.println("Derivative of class f2 : "+Numeric.derivative(b2,1.0));
  System.out.println("Derivative of fm1,0    : "+Numeric.derivative(b3,1,x,0));
  System.out.println("Derivative of fm2,0    : "+Numeric.derivative(b4,1,x,0));
  System.out.println("Derivative of fm1,0    : "+Numeric.derivative(b3,1,x,0));
  System.out.println("Derivative of fm2,0    : "+Numeric.derivative(b4,1,x,0));
}

}
