code: public static double dot(int[] x, int[] y) {
          if (x.length != y.length) {
              throw new IllegalArgumentException("Arrays have different length.");
          }
  
          double p = 0.0;
          for (int i = 0; i < x.length; i++) {
              p += x[i] * y[i];
          }
  
          return p;
      }
docs: Returns the dot product between two vectors.