Average Error: 25.3 → 9.9
Time: 4.8s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.653271416695378433251533453453101546377 \cdot 10^{159} \lor \neg \left(z \le 3.6212987406493825547877762167062528524 \cdot 10^{230}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1 \cdot \frac{y - z}{a - z}, t - x, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -2.653271416695378433251533453453101546377 \cdot 10^{159} \lor \neg \left(z \le 3.6212987406493825547877762167062528524 \cdot 10^{230}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r633508 = x;
        double r633509 = y;
        double r633510 = z;
        double r633511 = r633509 - r633510;
        double r633512 = t;
        double r633513 = r633512 - r633508;
        double r633514 = r633511 * r633513;
        double r633515 = a;
        double r633516 = r633515 - r633510;
        double r633517 = r633514 / r633516;
        double r633518 = r633508 + r633517;
        return r633518;
}

double f(double x, double y, double z, double t, double a) {
        double r633519 = z;
        double r633520 = -2.6532714166953784e+159;
        bool r633521 = r633519 <= r633520;
        double r633522 = 3.6212987406493826e+230;
        bool r633523 = r633519 <= r633522;
        double r633524 = !r633523;
        bool r633525 = r633521 || r633524;
        double r633526 = y;
        double r633527 = x;
        double r633528 = r633527 / r633519;
        double r633529 = t;
        double r633530 = r633529 / r633519;
        double r633531 = r633528 - r633530;
        double r633532 = fma(r633526, r633531, r633529);
        double r633533 = 1.0;
        double r633534 = r633526 - r633519;
        double r633535 = a;
        double r633536 = r633535 - r633519;
        double r633537 = r633534 / r633536;
        double r633538 = r633533 * r633537;
        double r633539 = r633529 - r633527;
        double r633540 = fma(r633538, r633539, r633527);
        double r633541 = r633525 ? r633532 : r633540;
        return r633541;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original25.3
Target11.7
Herbie9.9
\[\begin{array}{l} \mathbf{if}\;z \lt -1.253613105609503593846459977496550767343 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811028051510715777703865332 \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 z < -2.6532714166953784e+159 or 3.6212987406493826e+230 < z

    1. Initial program 50.1

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

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

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

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

    if -2.6532714166953784e+159 < z < 3.6212987406493826e+230

    1. Initial program 18.6

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

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

      \[\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 *-un-lft-identity8.7

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

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

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

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

Reproduce

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