code: private static double cosQ(double xa, double xb) {
          final double pi2a = 1.5707963267948966;
          final double pi2b = 6.123233995736766E-17;
  
          final double a = pi2a - xa;
          double b = -(a - pi2a + xa);
          b += pi2b - xb;
  
          return sinQ(a, b);
      }
docs: Compute cosine in the first quadrant by subtracting input from PI/2 and
  then calling sinQ.  This is more accurate as the input approaches PI/2.
  @param xa number from which cosine is requested
  @param xb extra bits for x (may be 0.0)
  @return cos(xa + xb)