code: private static Complex cdiv(double xr, double xi, double yr, double yi) {
          double cdivr, cdivi;
          double r, d;
          if (Math.abs(yr) > Math.abs(yi)) {
              r = yi / yr;
              d = yr + r * yi;
              cdivr = (xr + r * xi) / d;
              cdivi = (xi - r * xr) / d;
          } else {
              r = yr / yi;
              d = yi + r * yr;
              cdivr = (r * xr + xi) / d;
              cdivi = (r * xi - xr) / d;
          }
  
          return new Complex(cdivr, cdivi);
      }
docs: Complex scalar division.