Average Error: 7.6 → 6.1
Time: 3.3s
Precision: binary64
\[\]
\[\]
double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
double code(double x, double y, double z) {
	double tmp;
	if ((((x + y) / (1.0 - (y / z))) <= -7.571671828713221e-294) || !(((x + y) / (1.0 - (y / z))) <= -0.0)) {
		tmp = (x + y) / (1.0 - (y / z));
	} else {
		tmp = 1.0 / ((sqrt(1.0) + (sqrt(y) / sqrt(z))) * ((sqrt(1.0) - (sqrt(y) / sqrt(z))) / (x + y)));
	}
	return tmp;
}

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.6
Target4.0
Herbie6.1
\[\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (+ x y) (- 1.0 (/ y z))) < -7.5716718287132213e-294 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

      \[\]

    if -7.5716718287132213e-294 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 59.1

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

      \[\leadsto \]
    4. Using strategy rm
    5. Applied *-un-lft-identity59.1

      \[\leadsto \]
    6. Applied add-sqr-sqrt60.9

      \[\leadsto \]
    7. Applied add-sqr-sqrt62.6

      \[\leadsto \]
    8. Applied times-frac62.6

      \[\leadsto \]
    9. Applied add-sqr-sqrt62.6

      \[\leadsto \]
    10. Applied difference-of-squares62.6

      \[\leadsto \]
    11. Applied times-frac47.3

      \[\leadsto \]
    12. Simplified47.3

      \[\leadsto \]
    13. Simplified47.3

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

    \[\leadsto \]

Reproduce

herbie shell --seed 2020338 
(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))))