Average Error: 12.5 → 2.9
Time: 14.5s
Precision: 64
\[\frac{x \cdot \left(y - z\right)}{y}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.987697433686588590285611969201440389173 \cdot 10^{-172}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 1.318326588609397900170163534445278958933 \cdot 10^{-303}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \le -7.987697433686588590285611969201440389173 \cdot 10^{-172}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

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

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

\end{array}
double f(double x, double y, double z) {
        double r38468972 = x;
        double r38468973 = y;
        double r38468974 = z;
        double r38468975 = r38468973 - r38468974;
        double r38468976 = r38468972 * r38468975;
        double r38468977 = r38468976 / r38468973;
        return r38468977;
}

double f(double x, double y, double z) {
        double r38468978 = x;
        double r38468979 = -7.987697433686589e-172;
        bool r38468980 = r38468978 <= r38468979;
        double r38468981 = y;
        double r38468982 = z;
        double r38468983 = r38468981 - r38468982;
        double r38468984 = r38468983 / r38468981;
        double r38468985 = r38468978 * r38468984;
        double r38468986 = 1.3183265886093979e-303;
        bool r38468987 = r38468978 <= r38468986;
        double r38468988 = r38468982 * r38468978;
        double r38468989 = r38468988 / r38468981;
        double r38468990 = r38468978 - r38468989;
        double r38468991 = r38468981 / r38468983;
        double r38468992 = r38468978 / r38468991;
        double r38468993 = r38468987 ? r38468990 : r38468992;
        double r38468994 = r38468980 ? r38468985 : r38468993;
        return r38468994;
}

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.5
Target2.9
Herbie2.9
\[\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 < -7.987697433686589e-172

    1. Initial program 14.3

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

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

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

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

    if -7.987697433686589e-172 < x < 1.3183265886093979e-303

    1. Initial program 8.3

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

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

    if 1.3183265886093979e-303 < x

    1. Initial program 12.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.987697433686588590285611969201440389173 \cdot 10^{-172}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \le 1.318326588609397900170163534445278958933 \cdot 10^{-303}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array}\]

Reproduce

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

  :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))