Average Error: 11.2 → 6.3
Time: 3.1s
Precision: binary64
\[\]
\[\]
double code(double a1, double a2, double b1, double b2) {
	return ((double) (((double) (a1 * a2)) / ((double) (b1 * b2))));
}
double code(double a1, double a2, double b1, double b2) {
	double VAR;
	if ((((double) (b1 * b2)) <= -2.223137056513538e+153)) {
		VAR = ((double) (((double) (a2 * ((double) (a1 / b2)))) / b1));
	} else {
		double VAR_1;
		if ((((double) (b1 * b2)) <= -1.5147515431627668e-177)) {
			VAR_1 = ((double) (a1 * ((double) (a2 / ((double) (b1 * b2))))));
		} else {
			double VAR_2;
			if ((((double) (b1 * b2)) <= 1.1272910860476818e-228)) {
				VAR_2 = ((double) (((double) (a2 * ((double) (a1 / b1)))) * ((double) (1.0 / b2))));
			} else {
				double VAR_3;
				if ((((double) (b1 * b2)) <= 1.3195895724947344e+60)) {
					VAR_3 = ((double) (a1 * ((double) (a2 / ((double) (b1 * b2))))));
				} else {
					double VAR_4;
					if ((((double) (b1 * b2)) <= 1.45640378524597e+229)) {
						VAR_4 = ((double) (1.0 / ((double) (b2 * ((double) (b1 / ((double) (a2 * a1))))))));
					} else {
						VAR_4 = ((double) (a1 / ((double) (b1 * ((double) (b2 / a2))))));
					}
					VAR_3 = VAR_4;
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.2
Target11.5
Herbie6.3
\[\]

Derivation

  1. Split input into 5 regimes
  2. if (* b1 b2) < -2.22313705651353812e153

    1. Initial program 14.2

      \[\]
    2. Using strategy rm
    3. Applied associate-/r*8.7

      \[\leadsto \]
    4. Simplified6.1

      \[\leadsto \]
    5. Using strategy rm
    6. Applied div-inv6.1

      \[\leadsto \]
    7. Using strategy rm
    8. Applied associate-*r/8.7

      \[\leadsto \]
    9. Applied associate-*l/8.5

      \[\leadsto \]
    10. Simplified5.8

      \[\leadsto \]

    if -2.22313705651353812e153 < (* b1 b2) < -1.51475154316276679e-177 or 1.1272910860476818e-228 < (* b1 b2) < 1.31958957249473445e60

    1. Initial program 3.9

      \[\]
    2. Simplified3.7

      \[\leadsto \]

    if -1.51475154316276679e-177 < (* b1 b2) < 1.1272910860476818e-228

    1. Initial program 33.5

      \[\]
    2. Using strategy rm
    3. Applied associate-/r*18.1

      \[\leadsto \]
    4. Simplified9.5

      \[\leadsto \]
    5. Using strategy rm
    6. Applied div-inv9.6

      \[\leadsto \]

    if 1.31958957249473445e60 < (* b1 b2) < 1.45640378524596996e229

    1. Initial program 6.6

      \[\]
    2. Using strategy rm
    3. Applied clear-num7.1

      \[\leadsto \]
    4. Simplified11.7

      \[\leadsto \]

    if 1.45640378524596996e229 < (* b1 b2)

    1. Initial program 15.4

      \[\]
    2. Using strategy rm
    3. Applied associate-/l*15.4

      \[\leadsto \]
    4. Simplified7.0

      \[\leadsto \]
  3. Recombined 5 regimes into one program.
  4. Final simplification6.3

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"
  :precision binary64

  :herbie-target
  (* (/ a1 b1) (/ a2 b2))

  (/ (* a1 a2) (* b1 b2)))