import java.io.*;
import javax.swing.*;

class SCO11F5
{ 
  public static double [] B_cof(double xi[],double yi[])
  {
  int n=xi.length-1;
  double h[]=new double[n+2];
  double r,delta,gamma,p,q;
  double a[]=new double[n+4];
  int i;
  for(i=1;i<=n;i++) h[i]=yi[i]-yi[i-1];
  h[0]=h[1];
  h[n+1]=h[n];
  delta=-1.0;
  gamma=2.0*yi[0];
  p=delta*gamma;
  q=2.0; 
  for(i=1;i<=n;i++)
     {r=h[i+1]/h[i];
      delta=-r*delta;
      gamma=-r*gamma+(r+1)*yi[i];
      p+=gamma*delta;;
      q+=delta*delta;      
	 }
  a[0]=-p/q;
  for(i=1;i<=(n+1);i++)
     {a[i]=((h[i-1]+h[i])*yi[i-1]-h[i]*a[i-1])/h[i-1];}
  a[n+2]=xi[0];
  a[n+3]=xi[n];   
  return a;   
  }

  public static double [][] B_spline(double xi[],double yi[],int ns)
  {
  // ns degree of spline function  	  
  int n=xi.length;  //total number of data points
  int ndp;//number of data points  
  int nr;  //remaining data set
  ndp=n/(ns+1);
  nr=n-ndp*ns-1;
  double x[][]=new double[ndp+1][ns+1];
  double y[][]=new double[ndp+1][ns+1];  
  double a[][]=new double[ndp+1][ns+2];
    double xj[]=new double[nr+1];
    double yj[]=new double[nr+1];  
  int i;
  System.out.println("n="+n+"ndp = "+ndp+"nr="+nr);
  for(i=0;i<ndp;i++)
  { for(int j=0;j<=ns;j++){x[i][j]=xi[i*ns+j];y[i][j]=yi[i*ns+j];System.out.println(i*ns+j);}}
  {i=ndp; 
    for(int j=0;j<=ns;j++){x[i][j]=xi[i*ns-ns+nr+j];y[i][j]=yi[i*ns-ns+nr+j];System.out.println(i*ns+j);}}
  for(i=0;i<=ndp;i++)
   {a[i]=B_cof(x[i],y[i]);}
  return a; 	     	 
  }

  public static double funcB_Spline(double S[][],double x)
  {
  int n=a.length-1;
  int m=a[0].length;
  mm=m-2;
  double a[]=new double[m-2]
  for(int i=0;i<=n;i++) {if(x>=S[i][m-2]&&x<=S[i][m-1])for(int j=0;j<mm;j++){a[j]=S[i][j];}}
  
  return 1.0;
  }     
  /* 
 public static double[][]  funcSpline(double xi[],double yi[],int aradegersayisi)
 {
    return 1.0;
 } 
 */    
  public static void main(String args[]) throws IOException
  {  
  double x[];
  double y[];
  //JFileChooser fc=new JFileChooser();
  //if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {File file = fc.getSelectedFile();s1=file.getName(); }
    String s1=JOptionPane.showInputDialog("dosya adı : ");	  
  double a[][]=Text.readDoubleT(s1);
  
  x=a[0];
  y=a[1];
  /*
  int n=x.length;
  double t[]=new double [n];
  for(int i=0;i<n;i++) t[i]=i;
  double z1[][]=funcSpline(t,x,20);
  double z2[][]=funcSpline(t,y,20);
  //System.out.println(" z1\n"+Matrix.toString(z1)); 
  //System.out.println(" z2\n"+Matrix.toString(z1)); 
  Plot pp=new Plot(z1[1],z2[1]);
  pp.setPlabel("kübik şerit yöntemi ile parametrik eğri uydurma");
  pp.setXlabel("x");
  pp.setYlabel("y");
  pp.setPlotType(0,0);
  double aa[][]=new double[2][z1[0].length];
  for(int i=0;i<z1[1].length;i++) {aa[0][i]=z1[1][i];aa[1][i]=z2[1][i];}
  Text.print(Text.T(aa));  
  pp.addData(z1[1],z2[1]);
  pp.plot();
  */
  Text.print(Text.T(B_spline(x,y,3)));
  }
  }
