Average Error: 10.7 → 2.3
Time: 4.8s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.084388500328017 \cdot 10^{-163}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} - \frac{z}{a - z}, t, x\right)\\ \mathbf{elif}\;z \le -8.0781943604068975 \cdot 10^{-283}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{\left(y - z\right) \cdot t}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - z\right) \cdot \frac{t}{a - z}\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -2.084388500328017 \cdot 10^{-163}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} - \frac{z}{a - z}, t, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r490078 = x;
        double r490079 = y;
        double r490080 = z;
        double r490081 = r490079 - r490080;
        double r490082 = t;
        double r490083 = r490081 * r490082;
        double r490084 = a;
        double r490085 = r490084 - r490080;
        double r490086 = r490083 / r490085;
        double r490087 = r490078 + r490086;
        return r490087;
}

double f(double x, double y, double z, double t, double a) {
        double r490088 = z;
        double r490089 = -2.0843885003280172e-163;
        bool r490090 = r490088 <= r490089;
        double r490091 = y;
        double r490092 = a;
        double r490093 = r490092 - r490088;
        double r490094 = r490091 / r490093;
        double r490095 = r490088 / r490093;
        double r490096 = r490094 - r490095;
        double r490097 = t;
        double r490098 = x;
        double r490099 = fma(r490096, r490097, r490098);
        double r490100 = -8.0781943604068975e-283;
        bool r490101 = r490088 <= r490100;
        double r490102 = 1.0;
        double r490103 = r490091 - r490088;
        double r490104 = r490103 * r490097;
        double r490105 = r490093 / r490104;
        double r490106 = r490102 / r490105;
        double r490107 = r490098 + r490106;
        double r490108 = r490097 / r490093;
        double r490109 = r490103 * r490108;
        double r490110 = r490098 + r490109;
        double r490111 = r490101 ? r490107 : r490110;
        double r490112 = r490090 ? r490099 : r490111;
        return r490112;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original10.7
Target0.6
Herbie2.3
\[\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 z < -2.0843885003280172e-163

    1. Initial program 12.7

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

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

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

    if -2.0843885003280172e-163 < z < -8.0781943604068975e-283

    1. Initial program 3.5

      \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
    2. Using strategy rm
    3. Applied clear-num3.5

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

    if -8.0781943604068975e-283 < z

    1. Initial program 10.4

      \[x + \frac{\left(y - z\right) \cdot t}{a - z}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity10.4

      \[\leadsto x + \frac{\left(y - z\right) \cdot t}{\color{blue}{1 \cdot \left(a - z\right)}}\]
    4. Applied times-frac3.3

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

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

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

Reproduce

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