private double calculateWavedX(double x1, double x2, double x3, double f1, double f2, double f3)
            throws ArithmeticException{
        double r23 = Math.pow(x2, 2) - Math.pow(x3, 2),
               r31 = Math.pow(x3, 2) - Math.pow(x1, 2),
               r12 = Math.pow(x1, 2) - Math.pow(x2, 2),
               s23 = x2 - x3,
               s31 = x3 - x1,
               s12 = x1 - x2;

        // returns 0.5 * (beta) / (alpha)
        double beta  = f1 * r23 + f2 * r31 + f3 * r12,
               alpha = f1 * s23 + f2 * s31 + f3 * s12;
        if (alpha != 0) {
            return 0.5 * (beta) / (alpha);
        } else {
            throw new ArithmeticException("ERROR: Divide by null by calculating waved point");
        }
    }