Average Error: 12.4 → 1.8
Time: 13.1s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.290655561206783908563838071823474030955 \cdot 10^{97}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;x \le 2.731727571395544206998641716133386673057 \cdot 10^{-15}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{-y}{-\left(y - z\right)}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \le -1.290655561206783908563838071823474030955 \cdot 10^{97}:\\
\;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{-y}{-\left(y - z\right)}}\\

\end{array}
double f(double x, double y, double z) {
        double r603176 = x;
        double r603177 = y;
        double r603178 = z;
        double r603179 = r603177 - r603178;
        double r603180 = r603176 * r603179;
        double r603181 = r603180 / r603177;
        return r603181;
}

double f(double x, double y, double z) {
        double r603182 = x;
        double r603183 = -1.290655561206784e+97;
        bool r603184 = r603182 <= r603183;
        double r603185 = 1.0;
        double r603186 = z;
        double r603187 = y;
        double r603188 = r603186 / r603187;
        double r603189 = r603185 - r603188;
        double r603190 = r603189 * r603182;
        double r603191 = 2.7317275713955442e-15;
        bool r603192 = r603182 <= r603191;
        double r603193 = r603182 * r603186;
        double r603194 = r603193 / r603187;
        double r603195 = r603182 - r603194;
        double r603196 = -r603187;
        double r603197 = r603187 - r603186;
        double r603198 = -r603197;
        double r603199 = r603196 / r603198;
        double r603200 = r603182 / r603199;
        double r603201 = r603192 ? r603195 : r603200;
        double r603202 = r603184 ? r603190 : r603201;
        return r603202;
}

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.4
Target3.3
Herbie1.8
\[\begin{array}{l} \mathbf{if}\;z \lt -2.060202331921739024383612783691266533098 \cdot 10^{104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z \lt 1.693976601382852594702773997610248441465 \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 < -1.290655561206784e+97

    1. Initial program 31.2

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{y}{y - z}}{x}}}\]
    6. Using strategy rm
    7. Applied div-inv0.3

      \[\leadsto \frac{1}{\color{blue}{\frac{y}{y - z} \cdot \frac{1}{x}}}\]
    8. Applied add-cube-cbrt0.3

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{y}{y - z}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{x}}}\]
    10. Simplified0.2

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

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

    if -1.290655561206784e+97 < x < 2.7317275713955442e-15

    1. Initial program 5.6

      \[\frac{x \cdot \left(y - z\right)}{y}\]
    2. Taylor expanded around 0 2.7

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

    if 2.7317275713955442e-15 < x

    1. Initial program 20.8

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

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

      \[\leadsto \frac{x}{\color{blue}{\frac{-y}{-\left(y - z\right)}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.290655561206783908563838071823474030955 \cdot 10^{97}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;x \le 2.731727571395544206998641716133386673057 \cdot 10^{-15}:\\ \;\;\;\;x - \frac{x \cdot z}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{-y}{-\left(y - z\right)}}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< z -2.060202331921739e104) (- x (/ (* z x) y)) (if (< z 1.69397660138285259e213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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