Average Error: 12.0 → 2.6
Time: 9.7s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -4.727842335792455 \cdot 10^{-115}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 6.94029728708334437 \cdot 10^{-305}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{y}{y - z}}{x}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \le -4.727842335792455 \cdot 10^{-115}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;x \le 6.94029728708334437 \cdot 10^{-305}:\\
\;\;\;\;x - \frac{x \cdot z}{y}\\

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

\end{array}
double f(double x, double y, double z) {
        double r917929 = x;
        double r917930 = y;
        double r917931 = z;
        double r917932 = r917930 - r917931;
        double r917933 = r917929 * r917932;
        double r917934 = r917933 / r917930;
        return r917934;
}

double f(double x, double y, double z) {
        double r917935 = x;
        double r917936 = -4.727842335792455e-115;
        bool r917937 = r917935 <= r917936;
        double r917938 = y;
        double r917939 = z;
        double r917940 = r917938 - r917939;
        double r917941 = r917940 / r917938;
        double r917942 = r917935 * r917941;
        double r917943 = 6.940297287083344e-305;
        bool r917944 = r917935 <= r917943;
        double r917945 = r917935 * r917939;
        double r917946 = r917945 / r917938;
        double r917947 = r917935 - r917946;
        double r917948 = 1.0;
        double r917949 = r917938 / r917940;
        double r917950 = r917949 / r917935;
        double r917951 = r917948 / r917950;
        double r917952 = r917944 ? r917947 : r917951;
        double r917953 = r917937 ? r917942 : r917952;
        return r917953;
}

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

Original12.0
Target3.3
Herbie2.6
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.69397660138285259 \cdot 10^{213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -4.727842335792455e-115

    1. Initial program 14.6

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity14.6

      \[\leadsto \frac{x \cdot \left(y - z\right)}{\color{blue}{1 \cdot y}}\]
    4. Applied times-frac0.9

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y - z}{y}}\]
    5. Simplified0.9

      \[\leadsto \color{blue}{x} \cdot \frac{y - z}{y}\]

    if -4.727842335792455e-115 < x < 6.940297287083344e-305

    1. Initial program 7.2

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied associate-/l*7.3

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Taylor expanded around 0 4.0

      \[\leadsto \color{blue}{x - \frac{x \cdot z}{y}}\]

    if 6.940297287083344e-305 < x

    1. Initial program 12.1

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Using strategy rm
    3. Applied associate-/l*3.0

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}}\]
    4. Using strategy rm
    5. Applied div-inv3.2

      \[\leadsto \frac{x}{\color{blue}{y \cdot \frac{1}{y - z}}}\]
    6. Using strategy rm
    7. Applied clear-num3.2

      \[\leadsto \color{blue}{\frac{1}{\frac{y \cdot \frac{1}{y - z}}{x}}}\]
    8. Simplified3.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.727842335792455 \cdot 10^{-115}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 6.94029728708334437 \cdot 10^{-305}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\frac{y}{y - z}}{x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020046 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

  (/ (* x (- y z)) y))