fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. double K = 3.0;
  6. double L = 12.48;
  7. double[] xs = {2.005, -0.437, -2.47};
  8.  
  9. for (double x : xs) {
  10. if (x == 0) continue;
  11.  
  12. double a = Math.tan(Math.pow(Math.sqrt(K), Math.pow(K, 1.0/3.0))) - 1.0/(2.0*x);
  13.  
  14. double denomB = Math.pow(0.842, 4) * Math.sqrt(8 * K) * Math.cos(4 * x);
  15. if (denomB == 0) continue;
  16.  
  17. double b = (Math.sin(2 * x) * L * Math.pow(5.75, 1.0/3.0)) / denomB;
  18. double ab = a * b;
  19.  
  20. if (ab < 0) {
  21. double denomY = 2 * a + 5 * b;
  22. if (denomY != 0) {
  23. double y = (a - 2 * b) / denomY;
  24. System.out.printf("x: %.4f | a: %.4f | b: %.4f | y: %.4f%n", x, a, b, y);
  25. }
  26. } else {
  27. double y = Math.sqrt(ab);
  28. System.out.printf("x: %.4f | a: %.4f | b: %.4f | y: %.4f%n", x, a, b, y);
  29. }
  30. }
  31. }
  32. }
Success #stdin #stdout 0.11s 56132KB
stdin
Standard input is empty
stdout
x: 2.0050 | a: -1.5994 | b: 41.9392 | y: -0.4139
x: -0.4370 | a: -0.2059 | b: 39.5026 | y: -0.4019
x: -2.4700 | a: -1.1476 | b: -9.8487 | y: 3.3619