Average Error: 10.6 → 1.1
Time: 5.8s
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 -4.97230832957391549 \cdot 10^{-51}:\\ \;\;\;\;\frac{t}{a - z} \cdot \left(y - z\right) + x\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 2.87561695680123313 \cdot 10^{245}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} - \frac{z}{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 -4.97230832957391549 \cdot 10^{-51}:\\
\;\;\;\;\frac{t}{a - z} \cdot \left(y - z\right) + x\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r511565 = x;
        double r511566 = y;
        double r511567 = z;
        double r511568 = r511566 - r511567;
        double r511569 = t;
        double r511570 = r511568 * r511569;
        double r511571 = a;
        double r511572 = r511571 - r511567;
        double r511573 = r511570 / r511572;
        double r511574 = r511565 + r511573;
        return r511574;
}

double f(double x, double y, double z, double t, double a) {
        double r511575 = y;
        double r511576 = z;
        double r511577 = r511575 - r511576;
        double r511578 = t;
        double r511579 = r511577 * r511578;
        double r511580 = a;
        double r511581 = r511580 - r511576;
        double r511582 = r511579 / r511581;
        double r511583 = -4.9723083295739155e-51;
        bool r511584 = r511582 <= r511583;
        double r511585 = r511578 / r511581;
        double r511586 = r511585 * r511577;
        double r511587 = x;
        double r511588 = r511586 + r511587;
        double r511589 = 2.875616956801233e+245;
        bool r511590 = r511582 <= r511589;
        double r511591 = r511587 + r511582;
        double r511592 = r511575 / r511581;
        double r511593 = r511576 / r511581;
        double r511594 = r511592 - r511593;
        double r511595 = fma(r511594, r511578, r511587);
        double r511596 = r511590 ? r511591 : r511595;
        double r511597 = r511584 ? r511588 : r511596;
        return r511597;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.6
Target0.6
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;t \lt -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t \lt 3.9110949887586375 \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)) < -4.9723083295739155e-51

    1. Initial program 19.6

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - z}{y - z}} \cdot t + x}\]
    7. Simplified3.0

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

    if -4.9723083295739155e-51 < (/ (* (- y z) t) (- a z)) < 2.875616956801233e+245

    1. Initial program 0.2

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

    if 2.875616956801233e+245 < (/ (* (- y z) t) (- a z))

    1. Initial program 54.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\left(y - z\right) \cdot t}{a - z} \le -4.97230832957391549 \cdot 10^{-51}:\\ \;\;\;\;\frac{t}{a - z} \cdot \left(y - z\right) + x\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 2.87561695680123313 \cdot 10^{245}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} - \frac{z}{a - z}, t, x\right)\\ \end{array}\]

Reproduce

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

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