Average Error: 15.5 → 0.1
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 <= -1.667320367462466e+26) || !(y <= 2.291406381019822e+37))) {
		VAR = ((double) (((double) (((double) (y + x)) / y)) / ((double) (x * 2.0))));
	} else {
		VAR = ((double) (1.0 / ((double) (y * ((double) (x / ((double) (((double) (y + x)) / 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.1
\[\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.66732036746246606e26 or 2.29140638101982187e37 < y

    1. Initial program 17.1

      \[\]
    2. Using strategy rm
    3. Applied *-un-lft-identity17.1

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

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

      \[\leadsto \]
    7. Simplified0.1

      \[\leadsto \]

    if -1.66732036746246606e26 < y < 2.29140638101982187e37

    1. Initial program 14.2

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

      \[\leadsto \]
    4. Simplified0.1

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

    \[\leadsto \]

Reproduce

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

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

  (/ (+ x y) (* (* x 2.0) y)))