Average Error: 7.4 → 7.8
Time: 41.2s
Precision: 64
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;y \le 4.252183677385179002148581232137543065445 \cdot 10^{245}:\\ \;\;\;\;\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{x + y}}{\sqrt{1} - \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{x + y}}{\sqrt{1} + \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;y \le 4.252183677385179002148581232137543065445 \cdot 10^{245}:\\
\;\;\;\;\left(x + y\right) \cdot \frac{1}{1 - \frac{y}{z}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r31698728 = x;
        double r31698729 = y;
        double r31698730 = r31698728 + r31698729;
        double r31698731 = 1.0;
        double r31698732 = z;
        double r31698733 = r31698729 / r31698732;
        double r31698734 = r31698731 - r31698733;
        double r31698735 = r31698730 / r31698734;
        return r31698735;
}

double f(double x, double y, double z) {
        double r31698736 = y;
        double r31698737 = 4.252183677385179e+245;
        bool r31698738 = r31698736 <= r31698737;
        double r31698739 = x;
        double r31698740 = r31698739 + r31698736;
        double r31698741 = 1.0;
        double r31698742 = 1.0;
        double r31698743 = z;
        double r31698744 = r31698736 / r31698743;
        double r31698745 = r31698742 - r31698744;
        double r31698746 = r31698741 / r31698745;
        double r31698747 = r31698740 * r31698746;
        double r31698748 = sqrt(r31698740);
        double r31698749 = sqrt(r31698742);
        double r31698750 = sqrt(r31698736);
        double r31698751 = sqrt(r31698743);
        double r31698752 = r31698750 / r31698751;
        double r31698753 = r31698749 - r31698752;
        double r31698754 = r31698748 / r31698753;
        double r31698755 = r31698749 + r31698752;
        double r31698756 = r31698748 / r31698755;
        double r31698757 = r31698754 * r31698756;
        double r31698758 = r31698738 ? r31698747 : r31698757;
        return r31698758;
}

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
Target4.0
Herbie7.8
\[\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. Split input into 2 regimes
  2. if y < 4.252183677385179e+245

    1. Initial program 6.4

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

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

    if 4.252183677385179e+245 < y

    1. Initial program 26.5

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt45.0

      \[\leadsto \frac{x + y}{1 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\]
    4. Applied add-sqr-sqrt45.0

      \[\leadsto \frac{x + y}{1 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}\]
    5. Applied times-frac45.0

      \[\leadsto \frac{x + y}{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}\]
    6. Applied add-sqr-sqrt45.0

      \[\leadsto \frac{x + y}{\color{blue}{\sqrt{1} \cdot \sqrt{1}} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    7. Applied difference-of-squares45.0

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

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

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

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

Reproduce

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

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

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