Average Error: 24.2 → 7.4
Time: 6.9s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -3.6365486485991055 \cdot 10^{-160} \lor \neg \left(a \le 7.07551916214290112 \cdot 10^{-178}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z} + \mathsf{fma}\left(-x, \left(y - z\right) \cdot \frac{1}{a - z}, x\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{y - z}{a - z} + \frac{x \cdot y}{z}\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -3.6365486485991055 \cdot 10^{-160} \lor \neg \left(a \le 7.07551916214290112 \cdot 10^{-178}\right):\\
\;\;\;\;t \cdot \frac{y - z}{a - z} + \mathsf{fma}\left(-x, \left(y - z\right) \cdot \frac{1}{a - z}, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r599595 = x;
        double r599596 = y;
        double r599597 = z;
        double r599598 = r599596 - r599597;
        double r599599 = t;
        double r599600 = r599599 - r599595;
        double r599601 = r599598 * r599600;
        double r599602 = a;
        double r599603 = r599602 - r599597;
        double r599604 = r599601 / r599603;
        double r599605 = r599595 + r599604;
        return r599605;
}

double f(double x, double y, double z, double t, double a) {
        double r599606 = a;
        double r599607 = -3.6365486485991055e-160;
        bool r599608 = r599606 <= r599607;
        double r599609 = 7.075519162142901e-178;
        bool r599610 = r599606 <= r599609;
        double r599611 = !r599610;
        bool r599612 = r599608 || r599611;
        double r599613 = t;
        double r599614 = y;
        double r599615 = z;
        double r599616 = r599614 - r599615;
        double r599617 = r599606 - r599615;
        double r599618 = r599616 / r599617;
        double r599619 = r599613 * r599618;
        double r599620 = x;
        double r599621 = -r599620;
        double r599622 = 1.0;
        double r599623 = r599622 / r599617;
        double r599624 = r599616 * r599623;
        double r599625 = fma(r599621, r599624, r599620);
        double r599626 = r599619 + r599625;
        double r599627 = r599620 * r599614;
        double r599628 = r599627 / r599615;
        double r599629 = r599619 + r599628;
        double r599630 = r599612 ? r599626 : r599629;
        return r599630;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.2
Target12.0
Herbie7.4
\[\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 a < -3.6365486485991055e-160 or 7.075519162142901e-178 < a

    1. Initial program 22.9

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

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

      \[\leadsto \color{blue}{\frac{y - z}{a - z} \cdot \left(t - x\right) + x}\]
    5. Using strategy rm
    6. Applied sub-neg9.8

      \[\leadsto \frac{y - z}{a - z} \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    7. Applied distribute-rgt-in9.8

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

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

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

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

    if -3.6365486485991055e-160 < a < 7.075519162142901e-178

    1. Initial program 29.7

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

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

      \[\leadsto \color{blue}{\frac{y - z}{a - z} \cdot \left(t - x\right) + x}\]
    5. Using strategy rm
    6. Applied sub-neg19.7

      \[\leadsto \frac{y - z}{a - z} \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    7. Applied distribute-rgt-in19.7

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

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

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

      \[\leadsto t \cdot \frac{y - z}{a - z} + \color{blue}{\frac{x \cdot y}{z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.4

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

Reproduce

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