Average Error: 8.0 → 6.6
Time: 4.8s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -6.40202464514393151 \cdot 10^{-308} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -6.40202464514393151 \cdot 10^{-308} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\
\;\;\;\;\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\

\end{array}
double f(double x, double y, double z) {
        double r549771 = x;
        double r549772 = y;
        double r549773 = r549771 + r549772;
        double r549774 = 1.0;
        double r549775 = z;
        double r549776 = r549772 / r549775;
        double r549777 = r549774 - r549776;
        double r549778 = r549773 / r549777;
        return r549778;
}

double f(double x, double y, double z) {
        double r549779 = x;
        double r549780 = y;
        double r549781 = r549779 + r549780;
        double r549782 = 1.0;
        double r549783 = z;
        double r549784 = r549780 / r549783;
        double r549785 = r549782 - r549784;
        double r549786 = r549781 / r549785;
        double r549787 = -6.402024645143932e-308;
        bool r549788 = r549786 <= r549787;
        double r549789 = -0.0;
        bool r549790 = r549786 <= r549789;
        double r549791 = !r549790;
        bool r549792 = r549788 || r549791;
        double r549793 = 1.0;
        double r549794 = r549793 / r549785;
        double r549795 = r549781 * r549794;
        double r549796 = sqrt(r549782);
        double r549797 = sqrt(r549780);
        double r549798 = sqrt(r549783);
        double r549799 = r549797 / r549798;
        double r549800 = r549796 + r549799;
        double r549801 = r549781 / r549800;
        double r549802 = sqrt(r549793);
        double r549803 = r549796 - r549799;
        double r549804 = r549802 / r549803;
        double r549805 = r549801 * r549804;
        double r549806 = r549792 ? r549795 : r549805;
        return r549806;
}

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

Original8.0
Target3.9
Herbie6.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. Split input into 2 regimes
  2. if (/ (+ x y) (- 1.0 (/ y z))) < -6.402024645143932e-308 or -0.0 < (/ (+ x y) (- 1.0 (/ y z)))

    1. Initial program 0.1

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied div-inv0.2

      \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}}\]

    if -6.402024645143932e-308 < (/ (+ x y) (- 1.0 (/ y z))) < -0.0

    1. Initial program 60.1

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied div-inv60.1

      \[\leadsto \color{blue}{\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}}\]
    4. Using strategy rm
    5. Applied add-sqr-sqrt62.2

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\]
    6. Applied add-sqr-sqrt63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}\]
    7. Applied times-frac63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}\]
    8. Applied add-sqr-sqrt63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    9. Applied difference-of-squares63.1

      \[\leadsto \left(x + y\right) \cdot \frac{1}{\color{blue}{\left(\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    10. Applied add-sqr-sqrt63.1

      \[\leadsto \left(x + y\right) \cdot \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\left(\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}\right)}\]
    11. Applied times-frac62.3

      \[\leadsto \left(x + y\right) \cdot \color{blue}{\left(\frac{\sqrt{1}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\right)}\]
    12. Applied associate-*r*48.8

      \[\leadsto \color{blue}{\left(\left(x + y\right) \cdot \frac{\sqrt{1}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}\right) \cdot \frac{\sqrt{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}}\]
    13. Simplified48.8

      \[\leadsto \color{blue}{\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}} \cdot \frac{\sqrt{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \le -6.40202464514393151 \cdot 10^{-308} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \le -0.0\right):\\ \;\;\;\;\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{1}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020083 +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))))