import java.applet.Applet; import java.awt.*; import java.awt.event.*; import java.applet.*; import java.awt.geom.*; import java.math.*; public class EnergyEstimator { /**1 means eliminate. We add a small positive fudge factor of 2^{-40} to make this test more compatible with the interval arithmetic version. Adding this fudge factor makes the test HARDER to pass.**/ public static int[] eliminate(double e2,double E,BoxConfiguration X) { double[] e1=energyLowerBound(E,X); int[] test={0,(int)(e1[1])}; if(e1[0]>e2+Math.pow(.5,40)) test[0]=1; //pass return(test); } /**Here is the main energy estimate. The second number tells which index makes the biggest contribution to the error term.**/ public static double[] energyLowerBound(double E,BoxConfiguration X) { double e1=vertexEnergy(E,X); double[] e2=errorTerm(E,X); double t=e1-e2[0]; double[] d={t,e2[1]}; return(d); } public static double[] energyLowerBoundDebug(double E,BoxConfiguration X) { double e1=vertexEnergy(E,X); double[] e2=errorTerm(E,X); double t=e1-e2[0]; double[] d={t,e2[1]}; return(d); } /**This routine computes the energy at the 128 vertices of a dyadic box and then takes the min.**/ public static double vertexEnergy(double E,BoxConfiguration X) { double e=100000; double test=0; Complex[] Z=new Complex[4]; for(int n=0;n<128;++n) { Z=X.getConfiguration(n); test=Energy.energy(E,Z); if(e>test) e=test; } return(e); } /**Here is the error term. This follows the notation in the paper.**/ /**The whole thing. The first number is the error term. The second number tells which box makes the biggest contribution**/ public static double[] errorTerm(double E, BoxConfiguration X) { double total=0; double min=0; double test=0; int index=0; for(int i=0;i<4;++i) { test=errorTermSingleIndex(E,X,i); total=total+test; if(min