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

public class makPS  
{    
      public  static double Ps1(double t)
      {//ilk tanım Ps formülü	
      double T=t+273.15;
      double ln10=Math.log(10.0);
      double A[]={40.69889*ln10,-2.36254e3*ln10,-13.06883,7.616005e-3*ln10,0.2342564,3.761111e2};
      double p1=A[0]+A[1]/T+A[2]*Math.log(T)+A[3]*T+A[4]*((A[5]-T)/T)*Math.log(A[5]-T);
      return Math.exp(p1);
      }

	  public static double Ps2(double t)
      {
	  // t derece C 
      // sample specific function m dimensional independent variable
      // independent variables : x[0],x[1]...x[m-1]
      double ai[];
      ai=new double[6];
      ai[0] = -45.37032;
      ai[1] = 26233.885;
      ai[2] = 4.164859;
      double a4=ai[2];
      ai[3] = -0.11599104+0.29506258*a4*a4-0.00021222*a4*a4*a4*a4*a4;
      ai[4] = -0.01546028+0.0897816*a4*a4-0.05322199*a4*a4*a4;
      ai[5] = -0.05725757-0.06817687*a4+0.00047188*a4*a4*a4*a4*a4;  
      double T=t+273.15;
      double b0=ai[0];
      double b1=ai[1];
      double a5=ai[3];
      double a6=ai[4];
      double a7=ai[5];
      double Tc=374.23;
      double Tt=169.861;
      double Pt=0.42; //kPa
      double Pc=4056;
      double A=(Tc-Tt)/Tt;
      double tt=(T-Tt)/(Tc-Tt);
      double R=8.314471;
      double s=b0/R;
      double r=b1/(R*Tt)-s;
      double q=(1+A*tt);
      double rat=A*r*tt/q;
      //System.out.println("R="+R+"s="+s+"r="+r+"q="+q+"rat="+rat);
      double P0=1.0-Pt/(Pc-Pt)*(1-Math.pow(q,s)*Math.exp(rat));
      double tf=1-tt;
      double teta=0.199;
      double P1=2-a4*tf+a5*Math.pow(tf,(2.0-teta))+ a6*tf*tf*tf+a7*tf*tf*tf*tf;
      double N=87.0*Tt/Tc;
      double pi=Math.pow((Math.pow(P0,N)+Math.pow(P1,N)),(1.0/N));
      //System.out.println("P0="+P0+"P1="+P1+"pi="+pi+"N="+N);
      return (pi-1.0)*(Pc-Pt)+Pt; //kPa
      }
      
      public static double hata1(double x[],double y[])
      {
      //calculates absolute square root error of a least square approach
      double n=x.length;
      int k;
      double total=0;
      double yy=0;
      for(k=0;k<n;k++)
      {
	  yy=y[k]-Ps1(x[k]);
      total+=yy*yy;
      }
      total=Math.sqrt(total/(n-1));
      return total;
      }
      public static double hata2(double x[],double y[])
      {
      //calculates absolute square root error of a least square approach
      double n=x.length;
      int k;
      double total=0;
      double yy=0;
      for(k=0;k<n;k++)
      {
	  yy=y[k]-Ps2(x[k]);
      total+=yy*yy;
      }
      total=Math.sqrt(total/(n-1));
      return total;
      }
    public static void main(String args[]) throws IOException
  {
  //çok büyük veri setlerinde veriyi dosyadan okumamız gerekir
  String s1=JOptionPane.showInputDialog("dosya adı : ");	  
  double c[][]=Text.readDoubleT(s1);
  System.out.println("hata1 = "+hata1(c[0],c[1]));
  System.out.println("hata2 = "+hata2(c[0],c[1]));
  }
}