//======================================================
// Numerical Analysis package in java
// Gauss-Legendre integration utilizing
// user given terms, roots calculated by Legendre transform
// Dr. Turhan Coban
// =====================================================
import java.io.*;
import javax.swing.*;

public class gri_cisim2
{
public static double F(double x)
  {//Black body shape function
  double C2=1.438769e4;
  double y=C2/x;
  double total=0;
  for(int k=1;k<40;k++)
  {total+=Math.exp(-k*y)/k*(y*y*y+3.0*y*y/k+6.0*y/(k*k)+6.0/(k*k*k));}  
  double pi=Math.PI;
  total=15.0/(pi*pi*pi*pi)*total;
  return total;
  }
  public static double emmisivity(String filename,double T,double n)
  {double a[][]=Text.readDoubleT("a.txt");
  double lambda[]=a[0];
  double eps[]=a[1];
  int n1=lambda.length;
  double total=0;
  for(int i=1;i<n1;i++)
  {total+=(eps[i]+eps[i-1])/2.0*(F(lambda[i]*T*n)-F(lambda[i-1]*T*n));}
  total/=F(lambda[n1-1]*T*n)-F(lambda[0]*T*n);
   return total;
  }
  
  public static void main(String args[]) throws IOException
  {  
  double x=emmisivity("a.txt",5780.0,1.0);
  JOptionPane.showMessageDialog(null,"x="+x);
  }
}
