import java.io.*;

class f1 extends fi_xi
{
  double[] func(double[] x)
  {
  double b[];
  b=new double[2];
  b[0]=x[0]*x[0]-x[1]-1;
  b[1]=(x[0]-2)*(x[0]-2)+(x[1]-0.5)*(x[1]-0.5)-1.0;
  return b;
  }
}

class df1 extends fij_xi
{
  double[][] func(double x[])
  {
  double b[][];
  b=new double[2][2];
  b[0][0]=2.0*x[0];
  b[0][1]=-1.0;
  b[1][0]=2.0*x[0]-4.0;
  b[1][1]=2.0*x[1]-4.0;
  return b;
  }
}

class f2 extends f_x
{
 double func(double x)
 {
   return Math.sin(x)-x/2;
 }
}

class df2 extends f_x
{
 double func(double x)
 {
   return Math.cos(x)-0.5;
 }
}


class Matrix4
{
    public static void main(String args[]) throws IOException
    {
    f1 b1;
    b1=new f1();
    df1 db1;
    db1=new df1();
    f2 b2;
    b2=new f2();
    df2 db2;
    db2=new df2();
    double x[];
    x=new double[2];
    x[0]=0;
    x[1]=0.5;
    double xx=2.5;
    System.out.println("Newton y,dy x= "+Numeric.newton(xx,b2,db2));
    System.out.println("Newton y,   x= "+Numeric.newton(xx,b2));
    System.out.println("Newton_2nd_derivative y,dy x= "+Numeric.newton_2nd_derivative(xx,b2,db2));
    System.out.println("Newton_2nd_derivative y,   x= "+Numeric.newton_2nd_derivative(xx,b2));
    System.out.println("Secant_2nd_derivative y,   x= "+Numeric.secant_2nd_derivative(xx,b2));
    System.out.println(" "+Matrix.toString(Numeric.newton(x,b1,db1)));
    System.out.println(" "+Matrix.toString(Numeric.newton(x,b1)));

    }
}
