import java.util.Scanner; public class Main { static double xa; static double ya; static double xb; static double yb; public static void main(String[] args) { Scanner scan = new Scanner(System.in); xa = scan.nextDouble(); ya = scan.nextDouble(); xb = scan.nextDouble(); yb = scan.nextDouble(); scan.close(); double yp = 9; double r = Math.max(ya, yb); double l = Math.min(ya, yb); while(Math.abs(r - l) > 0.0000000001) { double y1 = (2.0 * l + r) / 3.0; double y2 = (l + 2.0 * r) / 3.0; // System.out.println(l + " " + r); // System.out.println(y1 + " " + y2); // System.out.println(diff1_func(y1) + " " + diff1_func(y2)); // System.out.println(); // if(Math.abs(diff1_func(y1)) < Math.abs(diff1_func(y2))) { // r = y2; // }else { // l = y1; // } if(func(y1) < func(y2)) { r = y2; }else { l = y1; } } yp = (l + r) / 2.0; System.out.println(yp); System.exit(0); for(int i = 0; i < 100; i++) { double yp_new = yp - diff1_func(yp) / diff2_func(yp); yp = yp_new; System.out.println(yp); } System.out.println(yp); } static double func(double yp) { return Math.pow(func1(yp), 0.5) + Math.pow(func2(yp), 0.5); } static double diff1_func(double yp) { return (yp - ya) * Math.pow(xa * xa + (yp - ya) * (yp - ya), -0.5) + (yp - yb) * Math.pow(xb * xb + (yp - yb) * (yp - yb), -0.5); } static double diff2_func(double yp) { return Math.pow(func1(yp), -0.5) - Math.pow(yp - ya, 2) * Math.pow(func1(yp), -1.5) + Math.pow(func2(yp), -0.5) - Math.pow(yp - yb, 2)* Math.pow(func2(yp), -1.5); } static double func1(double yp) { return xa * xa + (yp - ya) * (yp - ya); } static double func2(double yp) { return xb * xb + (yp - yb) * (yp - yb); } }