Average Error: 1.9 → 1.4
Time: 26.4s
Precision: 64
\[x + \left(y - x\right) \cdot \frac{z}{t}\]
\[\begin{array}{l} \mathbf{if}\;t \le -4.055611877349511902023060071737182375945 \cdot 10^{54}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \mathbf{elif}\;t \le 1.704391292344184374526926757329497765123 \cdot 10^{56}:\\ \;\;\;\;\left(\frac{z \cdot y}{t} - \frac{x \cdot z}{t}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \end{array}\]
x + \left(y - x\right) \cdot \frac{z}{t}
\begin{array}{l}
\mathbf{if}\;t \le -4.055611877349511902023060071737182375945 \cdot 10^{54}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\

\mathbf{elif}\;t \le 1.704391292344184374526926757329497765123 \cdot 10^{56}:\\
\;\;\;\;\left(\frac{z \cdot y}{t} - \frac{x \cdot z}{t}\right) + x\\

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

\end{array}
double f(double x, double y, double z, double t) {
        double r375963 = x;
        double r375964 = y;
        double r375965 = r375964 - r375963;
        double r375966 = z;
        double r375967 = t;
        double r375968 = r375966 / r375967;
        double r375969 = r375965 * r375968;
        double r375970 = r375963 + r375969;
        return r375970;
}

double f(double x, double y, double z, double t) {
        double r375971 = t;
        double r375972 = -4.055611877349512e+54;
        bool r375973 = r375971 <= r375972;
        double r375974 = y;
        double r375975 = x;
        double r375976 = r375974 - r375975;
        double r375977 = z;
        double r375978 = r375977 / r375971;
        double r375979 = fma(r375976, r375978, r375975);
        double r375980 = 1.7043912923441844e+56;
        bool r375981 = r375971 <= r375980;
        double r375982 = r375977 * r375974;
        double r375983 = r375982 / r375971;
        double r375984 = r375975 * r375977;
        double r375985 = r375984 / r375971;
        double r375986 = r375983 - r375985;
        double r375987 = r375986 + r375975;
        double r375988 = r375976 / r375971;
        double r375989 = fma(r375988, r375977, r375975);
        double r375990 = r375981 ? r375987 : r375989;
        double r375991 = r375973 ? r375979 : r375990;
        return r375991;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original1.9
Target2.0
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;\left(y - x\right) \cdot \frac{z}{t} \lt -1013646692435.88671875:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \mathbf{elif}\;\left(y - x\right) \cdot \frac{z}{t} \lt -0.0:\\ \;\;\;\;x + \frac{\left(y - x\right) \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{\frac{t}{z}}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -4.055611877349512e+54

    1. Initial program 1.0

      \[x + \left(y - x\right) \cdot \frac{z}{t}\]
    2. Simplified1.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)}\]

    if -4.055611877349512e+54 < t < 1.7043912923441844e+56

    1. Initial program 2.8

      \[x + \left(y - x\right) \cdot \frac{z}{t}\]
    2. Simplified2.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef2.8

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \frac{z}{t} + x}\]
    5. Simplified2.5

      \[\leadsto \color{blue}{\frac{y - x}{\frac{t}{z}}} + x\]
    6. Taylor expanded around 0 1.7

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

    if 1.7043912923441844e+56 < t

    1. Initial program 1.0

      \[x + \left(y - x\right) \cdot \frac{z}{t}\]
    2. Simplified1.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)}\]
    3. Using strategy rm
    4. Applied fma-udef1.0

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

      \[\leadsto \color{blue}{\frac{y - x}{\frac{t}{z}}} + x\]
    6. Using strategy rm
    7. Applied associate-/r/1.4

      \[\leadsto \color{blue}{\frac{y - x}{t} \cdot z} + x\]
    8. Applied fma-def1.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -4.055611877349511902023060071737182375945 \cdot 10^{54}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)\\ \mathbf{elif}\;t \le 1.704391292344184374526926757329497765123 \cdot 10^{56}:\\ \;\;\;\;\left(\frac{z \cdot y}{t} - \frac{x \cdot z}{t}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, z, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019208 +o rules:numerics
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
  :precision binary64

  :herbie-target
  (if (< (* (- y x) (/ z t)) -1013646692435.887) (+ x (/ (- y x) (/ t z))) (if (< (* (- y x) (/ z t)) -0.0) (+ x (/ (* (- y x) z) t)) (+ x (/ (- y x) (/ t z)))))

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