Average Error: 15.5 → 0.2
Time: 1.7s
Precision: binary64
\[\]
\[\]
double code(double x, double y) {
	return ((double) (((double) (x - y)) / ((double) (((double) (x * 2.0)) * y))));
}
double code(double x, double y) {
	double VAR;
	if (((y <= -4.3510246037590785e+67) || !(y <= 2.434587238763775e-17))) {
		VAR = ((double) (((double) (((double) (x / y)) + -1.0)) / ((double) (x * 2.0))));
	} else {
		VAR = ((double) (1.0 / ((double) (y * ((double) (x / ((double) (((double) (x - y)) / 2.0))))))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.5
Target0.0
Herbie0.2
\[\]

Derivation

  1. Split input into 2 regimes
  2. if y < -4.351024603759079e67 or 2.43458723876377507e-17 < y

    1. Initial program 16.9

      \[\]
    2. Using strategy rm
    3. Applied *-un-lft-identity16.9

      \[\leadsto \]
    4. Applied times-frac0.1

      \[\leadsto \]
    5. Simplified0.1

      \[\leadsto \]
    6. Using strategy rm
    7. Applied associate-*l/0.1

      \[\leadsto \]
    8. Simplified0.1

      \[\leadsto \]

    if -4.351024603759079e67 < y < 2.43458723876377507e-17

    1. Initial program 14.3

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

      \[\leadsto \]
    4. Simplified0.2

      \[\leadsto \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (x y)
  :name "Linear.Projection:inversePerspective from linear-1.19.1.3, B"
  :precision binary64

  :herbie-target
  (- (/ 0.5 y) (/ 0.5 x))

  (/ (- x y) (* (* x 2.0) y)))