import java.math.BigDecimal; import java.math.BigInteger; import javax.swing.JLabel; import javax.swing.JTextField; import java.awt.*; import java.awt.event.*; import java.applet.Applet; public class CauchySequence extends Applet implements ActionListener{ private static final long serialVersionUID = -6724959421340457497L; JTextField yx = new JTextField("100000"); JTextField yn = new JTextField("100000"); JLabel label1 = new JLabel("Convergence of Cauchy sequence",JLabel.CENTER); JLabel label2 = new JLabel("A natural number, 0= Math.pow(10.0,8) || x!=(long)x){ x=100000; } } if(e.getSource()==yn){ n = Double.valueOf(yn.getText()).doubleValue(); BigDecimal n0 = new BigDecimal(yn.getText()); BigDecimal n1 = new BigDecimal(Math.pow(0.1,16)); BigDecimal n2 = new BigDecimal(Math.pow(10.0,16)); int d1 = n0.compareTo(n1); int d2 = n0.compareTo(n2); if(d1==-1 || d1==0 || d2==0 || d2==1){ n=100000; } } yx.setText(""+(long)x); yn.setText(""+n); repaint(); } public void paint(Graphics g){ // variable set int i; double b, m, p, y, minp, maxp, minb, maxb; BigDecimal a0, a2, b0, n0, p0, p1, x0; BigInteger a1; double[] pp = new double[1000]; double[] bb = new double[1000]; int[] xxx = new int[1000]; int[] yyy = new int[1000]; for(i=1;i<=1000;i++){ p = Math.exp(10-0.01*i); m = n/p; p0 = new BigDecimal(p); n0 = new BigDecimal(n); p1 = n0.divide(p0,30,BigDecimal.ROUND_HALF_EVEN); pp[i-1] = Math.log(m); y = Math.sqrt(x); x0 = new BigDecimal(y); a0 = x0.multiply(p1); a1 = a0.toBigInteger(); a2 = new BigDecimal(a1); b0 = a2.divide(p1,30,BigDecimal.ROUND_HALF_EVEN); b = b0.doubleValue(); bb[i-1] = b; } minp = pp[0]; maxp = pp[0]; minb = bb[0]; maxb = bb[0]; for(i=0;i<=999;i++){ if(pp[i]>maxp){ maxp = pp[i]; } } for(i=0;i<=999;i++){ if(pp[i]maxb){ maxb = bb[i]; } } for(i=0;i<=999;i++){ if(bb[i]