Average Error: 10.6 → 0.6
Time: 5.1s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;t \le -8.6817706718888892 \cdot 10^{-50} \lor \neg \left(t \le 3.2416800356080724 \cdot 10^{-85}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{\left(y - z\right) \cdot t}{a - z} + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;t \le -8.6817706718888892 \cdot 10^{-50} \lor \neg \left(t \le 3.2416800356080724 \cdot 10^{-85}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, t, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r579775 = x;
        double r579776 = y;
        double r579777 = z;
        double r579778 = r579776 - r579777;
        double r579779 = t;
        double r579780 = r579778 * r579779;
        double r579781 = a;
        double r579782 = r579781 - r579777;
        double r579783 = r579780 / r579782;
        double r579784 = r579775 + r579783;
        return r579784;
}

double f(double x, double y, double z, double t, double a) {
        double r579785 = t;
        double r579786 = -8.68177067188889e-50;
        bool r579787 = r579785 <= r579786;
        double r579788 = 3.2416800356080724e-85;
        bool r579789 = r579785 <= r579788;
        double r579790 = !r579789;
        bool r579791 = r579787 || r579790;
        double r579792 = 1.0;
        double r579793 = a;
        double r579794 = z;
        double r579795 = r579793 - r579794;
        double r579796 = y;
        double r579797 = r579796 - r579794;
        double r579798 = r579795 / r579797;
        double r579799 = r579792 / r579798;
        double r579800 = x;
        double r579801 = fma(r579799, r579785, r579800);
        double r579802 = r579797 * r579785;
        double r579803 = r579802 / r579795;
        double r579804 = r579792 * r579803;
        double r579805 = r579804 + r579800;
        double r579806 = r579791 ? r579801 : r579805;
        return r579806;
}

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
Herbie0.6
\[\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 2 regimes
  2. if t < -8.68177067188889e-50 or 3.2416800356080724e-85 < t

    1. Initial program 18.0

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

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

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

    if -8.68177067188889e-50 < t < 3.2416800356080724e-85

    1. Initial program 0.5

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

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

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

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

      \[\leadsto \color{blue}{\frac{t}{a - z} \cdot \left(y - z\right)} + x\]
    8. Using strategy rm
    9. Applied *-un-lft-identity4.1

      \[\leadsto \color{blue}{\left(1 \cdot \frac{t}{a - z}\right)} \cdot \left(y - z\right) + x\]
    10. Applied associate-*l*4.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -8.6817706718888892 \cdot 10^{-50} \lor \neg \left(t \le 3.2416800356080724 \cdot 10^{-85}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y - z}}, t, x\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \frac{\left(y - z\right) \cdot t}{a - z} + x\\ \end{array}\]

Reproduce

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