Average Error: 7.7 → 0.3
Time: 3.5s
Precision: binary64
\[\]
\[\]
double code(double x, double y, double z) {
	return ((double) (((double) (x + y)) / ((double) (1.0 - ((double) (y / z))))));
}
double code(double x, double y, double z) {
	double VAR;
	if (((y <= -1.2075343199884464e+53) || !(y <= 3.4739094143059343e-06))) {
		VAR = ((double) (1.0 / ((double) (((double) (1.0 / ((double) (y + x)))) + ((double) (((double) (y / ((double) (y + x)))) * ((double) (-1.0 / z))))))));
	} else {
		VAR = ((double) (((double) (y + x)) * ((double) (1.0 / ((double) (1.0 - ((double) (y / z))))))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.7
Target4.0
Herbie0.3
\[\]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.20753431998844645e53 or 3.4739094143059343e-6 < y

    1. Initial program 16.2

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

      \[\leadsto \]
    4. Using strategy rm
    5. Applied div-sub16.3

      \[\leadsto \]
    6. Simplified16.3

      \[\leadsto \]
    7. Simplified10.3

      \[\leadsto \]
    8. Using strategy rm
    9. Applied *-un-lft-identity10.3

      \[\leadsto \]
    10. Applied times-frac0.2

      \[\leadsto \]

    if -1.20753431998844645e53 < y < 3.4739094143059343e-6

    1. Initial program 0.3

      \[\]
    2. Using strategy rm
    3. Applied div-inv0.3

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020192 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :herbie-target
  (if (< y -3.7429310762689856e+171) (* (/ (+ y x) (neg y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (neg y)) z)))

  (/ (+ x y) (- 1.0 (/ y z))))