Average Error: 10.8 → 0.5
Time: 4.4s
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.3247103441648892 \cdot 10^{265}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\ \mathbf{elif}\;\frac{\left(y - z\right) \cdot t}{a - z} \le 2.2768173042152343 \cdot 10^{278}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{a - z} \cdot \left(y - z\right) + x\\ \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.3247103441648892 \cdot 10^{265}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r520823 = x;
        double r520824 = y;
        double r520825 = z;
        double r520826 = r520824 - r520825;
        double r520827 = t;
        double r520828 = r520826 * r520827;
        double r520829 = a;
        double r520830 = r520829 - r520825;
        double r520831 = r520828 / r520830;
        double r520832 = r520823 + r520831;
        return r520832;
}

double f(double x, double y, double z, double t, double a) {
        double r520833 = y;
        double r520834 = z;
        double r520835 = r520833 - r520834;
        double r520836 = t;
        double r520837 = r520835 * r520836;
        double r520838 = a;
        double r520839 = r520838 - r520834;
        double r520840 = r520837 / r520839;
        double r520841 = -1.3247103441648892e+265;
        bool r520842 = r520840 <= r520841;
        double r520843 = r520835 / r520839;
        double r520844 = x;
        double r520845 = fma(r520843, r520836, r520844);
        double r520846 = 2.2768173042152343e+278;
        bool r520847 = r520840 <= r520846;
        double r520848 = r520844 + r520840;
        double r520849 = r520836 / r520839;
        double r520850 = r520849 * r520835;
        double r520851 = r520850 + r520844;
        double r520852 = r520847 ? r520848 : r520851;
        double r520853 = r520842 ? r520845 : r520852;
        return r520853;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.8
Target0.6
Herbie0.5
\[\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)) < -1.3247103441648892e+265

    1. Initial program 56.9

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

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

    if -1.3247103441648892e+265 < (/ (* (- y z) t) (- a z)) < 2.2768173042152343e+278

    1. Initial program 0.3

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

    if 2.2768173042152343e+278 < (/ (* (- y z) t) (- a z))

    1. Initial program 59.9

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

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

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

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

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

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

Reproduce

herbie shell --seed 2020089 +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))))