Average Error: 10.4 → 0.3
Time: 17.5s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} \le -1.513228984898154949568881114531259870315 \cdot 10^{300}:\\ \;\;\;\;\mathsf{fma}\left(y - z, t \cdot \frac{1}{a - z}, x\right)\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 2.936980270903230148646918893477206039603 \cdot 10^{302}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - z, \frac{1}{\frac{a - z}{t}}, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} \le -1.513228984898154949568881114531259870315 \cdot 10^{300}:\\
\;\;\;\;\mathsf{fma}\left(y - z, t \cdot \frac{1}{a - z}, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r515716 = x;
        double r515717 = y;
        double r515718 = z;
        double r515719 = r515717 - r515718;
        double r515720 = t;
        double r515721 = r515719 * r515720;
        double r515722 = a;
        double r515723 = r515722 - r515718;
        double r515724 = r515721 / r515723;
        double r515725 = r515716 + r515724;
        return r515725;
}

double f(double x, double y, double z, double t, double a) {
        double r515726 = y;
        double r515727 = z;
        double r515728 = r515726 - r515727;
        double r515729 = t;
        double r515730 = r515728 * r515729;
        double r515731 = a;
        double r515732 = r515731 - r515727;
        double r515733 = r515730 / r515732;
        double r515734 = -1.513228984898155e+300;
        bool r515735 = r515733 <= r515734;
        double r515736 = 1.0;
        double r515737 = r515736 / r515732;
        double r515738 = r515729 * r515737;
        double r515739 = x;
        double r515740 = fma(r515728, r515738, r515739);
        double r515741 = 2.93698027090323e+302;
        bool r515742 = r515733 <= r515741;
        double r515743 = r515739 + r515733;
        double r515744 = r515732 / r515729;
        double r515745 = r515736 / r515744;
        double r515746 = fma(r515728, r515745, r515739);
        double r515747 = r515742 ? r515743 : r515746;
        double r515748 = r515735 ? r515740 : r515747;
        return r515748;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.4
Target0.5
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;t \lt -1.068297449017406694366747246993994850729 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.911094988758637497591020599238553861375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* (- y z) t) (- a z)) < -1.513228984898155e+300

    1. Initial program 62.8

      \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
    2. Simplified0.6

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

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

    if -1.513228984898155e+300 < (/ (* (- y z) t) (- a z)) < 2.93698027090323e+302

    1. Initial program 0.3

      \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
    2. Simplified3.4

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

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

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

    if 2.93698027090323e+302 < (/ (* (- y z) t) (- a z))

    1. Initial program 63.0

      \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
    2. Simplified0.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} \le -1.513228984898154949568881114531259870315 \cdot 10^{300}:\\ \;\;\;\;\mathsf{fma}\left(y - z, t \cdot \frac{1}{a - z}, x\right)\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 2.936980270903230148646918893477206039603 \cdot 10^{302}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - z, \frac{1}{\frac{a - z}{t}}, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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