public static void main(String[] args) {
double x, E, R, S, y, x2;
int k;
Scanner inp = new Scanner(System.in);
System.out.print(" x = ");
x = inp.nextDouble();
System.out.print(" E = ");
E = inp.nextDouble();
inp.close();
x2 = x*x;
y = 0;
k = 1;
R = x*x;
S = R/2;
do {
k = k + 1 ;
R = (-R*x2)/(2 * k * (2 * k - 1));
S = R + S;
} while (Math.abs(R / S) > E && k < 1000) ;
if (k == 1000)
System.out.println("Ошибка");
else {
y = x * Math.atan(x) - Math.log(Math.sqrt(1 + x * x));
}
System.out.printf ("S = %1.8f\n",S);
System.out.printf("y = %1.8f\n", y);
System.out.printf("E = %1.8f\n", Math.abs(S - y));
System.out.printf("k = %d", k);
}
