Average Error: 24.6 → 8.9
Time: 5.1s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -9.4142096943048169 \cdot 10^{-269} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 1.57255 \cdot 10^{-235}\right):\\ \;\;\;\;\mathsf{fma}\left({\left(\frac{y - z}{a - z}\right)}^{1}, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -9.4142096943048169 \cdot 10^{-269} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 1.57255 \cdot 10^{-235}\right):\\
\;\;\;\;\mathsf{fma}\left({\left(\frac{y - z}{a - z}\right)}^{1}, t - x, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r668287 = x;
        double r668288 = y;
        double r668289 = z;
        double r668290 = r668288 - r668289;
        double r668291 = t;
        double r668292 = r668291 - r668287;
        double r668293 = r668290 * r668292;
        double r668294 = a;
        double r668295 = r668294 - r668289;
        double r668296 = r668293 / r668295;
        double r668297 = r668287 + r668296;
        return r668297;
}

double f(double x, double y, double z, double t, double a) {
        double r668298 = x;
        double r668299 = y;
        double r668300 = z;
        double r668301 = r668299 - r668300;
        double r668302 = t;
        double r668303 = r668302 - r668298;
        double r668304 = r668301 * r668303;
        double r668305 = a;
        double r668306 = r668305 - r668300;
        double r668307 = r668304 / r668306;
        double r668308 = r668298 + r668307;
        double r668309 = -9.414209694304817e-269;
        bool r668310 = r668308 <= r668309;
        double r668311 = 1.5725460863274251e-235;
        bool r668312 = r668308 <= r668311;
        double r668313 = !r668312;
        bool r668314 = r668310 || r668313;
        double r668315 = r668301 / r668306;
        double r668316 = 1.0;
        double r668317 = pow(r668315, r668316);
        double r668318 = fma(r668317, r668303, r668298);
        double r668319 = r668298 / r668300;
        double r668320 = r668302 / r668300;
        double r668321 = r668319 - r668320;
        double r668322 = fma(r668299, r668321, r668302);
        double r668323 = r668314 ? r668318 : r668322;
        return r668323;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target12.0
Herbie8.9
\[\begin{array}{l} \mathbf{if}\;z \lt -1.25361310560950359 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.44670236911381103 \cdot 10^{64}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (+ x (/ (* (- y z) (- t x)) (- a z))) < -9.414209694304817e-269 or 1.5725460863274251e-235 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.4

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y - z\right)}^{1}} \cdot {\left(\frac{1}{a - z}\right)}^{1}, t - x, x\right)\]
    8. Applied pow-prod-down7.1

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

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

    if -9.414209694304817e-269 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 1.5725460863274251e-235

    1. Initial program 52.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)}\]
    3. Taylor expanded around inf 23.2

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

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

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

Reproduce

herbie shell --seed 2020060 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

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