Average Error: 11.6 → 5.5
Time: 4.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)) <= -3.720837941461105e+286)) {
		VAR = ((double) (((double) (a1 / b1)) * ((double) (a2 / b2))));
	} else {
		double VAR_1;
		if ((((double) (b1 * b2)) <= -2.5109760299961963e-213)) {
			VAR_1 = ((double) (a2 * ((double) (a1 / ((double) (b1 * b2))))));
		} else {
			double VAR_2;
			if ((((double) (b1 * b2)) <= 2.4380641353373e-314)) {
				VAR_2 = ((double) (1.0 / ((double) (b2 * ((double) (((double) (1.0 / a1)) * ((double) (b1 / a2))))))));
			} else {
				double VAR_3;
				if ((((double) (b1 * b2)) <= 8.308086189259792e+220)) {
					VAR_3 = ((double) (a2 * ((double) (a1 / ((double) (b1 * b2))))));
				} else {
					VAR_3 = ((double) (((double) (((double) (a1 / b1)) * a2)) / b2));
				}
				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.6
Target11.9
Herbie5.5
\[\]

Derivation

  1. Split input into 4 regimes
  2. if (* b1 b2) < -3.720837941461105e286

    1. Initial program 20.1

      \[\]
    2. Using strategy rm
    3. Applied times-frac3.6

      \[\leadsto \]

    if -3.720837941461105e286 < (* b1 b2) < -2.51097602999619632e-213 or 2.43806413534e-314 < (* b1 b2) < 8.30808618925979213e220

    1. Initial program 5.1

      \[\]
    2. Taylor expanded around 0 5.1

      \[\leadsto \]
    3. Simplified5.3

      \[\leadsto \]

    if -2.51097602999619632e-213 < (* b1 b2) < 2.43806413534e-314

    1. Initial program 43.1

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

      \[\leadsto \]
    4. Simplified18.2

      \[\leadsto \]
    5. Using strategy rm
    6. Applied *-un-lft-identity18.2

      \[\leadsto \]
    7. Applied times-frac8.7

      \[\leadsto \]

    if 8.30808618925979213e220 < (* b1 b2)

    1. Initial program 17.2

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

      \[\leadsto \]
    4. Simplified5.1

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

    \[\leadsto \]

Reproduce

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

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

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