Average Error: 7.4 → 1.6
Time: 6.2s
Precision: binary64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\frac{1}{\frac{1}{y + x} - \frac{\frac{y}{y + x}}{z}}\]
\frac{x + y}{1 - \frac{y}{z}}
\frac{1}{\frac{1}{y + x} - \frac{\frac{y}{y + x}}{z}}
double code(double x, double y, double z) {
	return (((double) (x + y)) / ((double) (1.0 - (y / z))));
}
double code(double x, double y, double z) {
	return (1.0 / ((double) ((1.0 / ((double) (y + x))) - ((y / ((double) (y + x))) / z))));
}

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.4
Target3.8
Herbie1.6
\[\begin{array}{l} \mathbf{if}\;y \lt -3.74293107626898565 \cdot 10^{171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.55346624560867344 \cdot 10^{168}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \end{array}\]

Derivation

  1. Initial program 7.4

    \[\frac{x + y}{1 - \frac{y}{z}}\]
  2. Using strategy rm
  3. Applied clear-num7.6

    \[\leadsto \color{blue}{\frac{1}{\frac{1 - \frac{y}{z}}{x + y}}}\]
  4. Using strategy rm
  5. Applied div-sub7.6

    \[\leadsto \frac{1}{\color{blue}{\frac{1}{x + y} - \frac{\frac{y}{z}}{x + y}}}\]
  6. Simplified7.6

    \[\leadsto \frac{1}{\color{blue}{\frac{1}{y + x}} - \frac{\frac{y}{z}}{x + y}}\]
  7. Simplified6.8

    \[\leadsto \frac{1}{\frac{1}{y + x} - \color{blue}{\frac{y}{\left(y + x\right) \cdot z}}}\]
  8. Using strategy rm
  9. Applied associate-/r*1.6

    \[\leadsto \frac{1}{\frac{1}{y + x} - \color{blue}{\frac{\frac{y}{y + x}}{z}}}\]
  10. Final simplification1.6

    \[\leadsto \frac{1}{\frac{1}{y + x} - \frac{\frac{y}{y + x}}{z}}\]

Reproduce

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