Average Error: 7.6 → 7.6
Time: 6.5s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\frac{x + y}{1 - \frac{y}{z}}\]
\frac{x + y}{1 - \frac{y}{z}}
\frac{x + y}{1 - \frac{y}{z}}
double f(double x, double y, double z) {
        double r683127 = x;
        double r683128 = y;
        double r683129 = r683127 + r683128;
        double r683130 = 1.0;
        double r683131 = z;
        double r683132 = r683128 / r683131;
        double r683133 = r683130 - r683132;
        double r683134 = r683129 / r683133;
        return r683134;
}

double f(double x, double y, double z) {
        double r683135 = x;
        double r683136 = y;
        double r683137 = r683135 + r683136;
        double r683138 = 1.0;
        double r683139 = z;
        double r683140 = r683136 / r683139;
        double r683141 = r683138 - r683140;
        double r683142 = r683137 / r683141;
        return r683142;
}

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
Target3.8
Herbie7.6
\[\begin{array}{l} \mathbf{if}\;y \lt -3.742931076268985646434612946949172132145 \cdot 10^{171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y \lt 3.553466245608673435460441960303815115662 \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.6

    \[\frac{x + y}{1 - \frac{y}{z}}\]
  2. Final simplification7.6

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

Reproduce

herbie shell --seed 2020002 +o rules:numerics
(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) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z)))

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