Average Error: 24.7 → 8.6
Time: 18.7s
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 -1.034567205203707255381370590550516843978 \cdot 10^{-307} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{a - z}, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\ \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 -1.034567205203707255381370590550516843978 \cdot 10^{-307} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\
\;\;\;\;\mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{a - z}, t - x, x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r1121524 = x;
        double r1121525 = y;
        double r1121526 = z;
        double r1121527 = r1121525 - r1121526;
        double r1121528 = t;
        double r1121529 = r1121528 - r1121524;
        double r1121530 = r1121527 * r1121529;
        double r1121531 = a;
        double r1121532 = r1121531 - r1121526;
        double r1121533 = r1121530 / r1121532;
        double r1121534 = r1121524 + r1121533;
        return r1121534;
}

double f(double x, double y, double z, double t, double a) {
        double r1121535 = x;
        double r1121536 = y;
        double r1121537 = z;
        double r1121538 = r1121536 - r1121537;
        double r1121539 = t;
        double r1121540 = r1121539 - r1121535;
        double r1121541 = r1121538 * r1121540;
        double r1121542 = a;
        double r1121543 = r1121542 - r1121537;
        double r1121544 = r1121541 / r1121543;
        double r1121545 = r1121535 + r1121544;
        double r1121546 = -1.0345672052037073e-307;
        bool r1121547 = r1121545 <= r1121546;
        double r1121548 = 0.0;
        bool r1121549 = r1121545 <= r1121548;
        double r1121550 = !r1121549;
        bool r1121551 = r1121547 || r1121550;
        double r1121552 = 1.0;
        double r1121553 = r1121552 / r1121543;
        double r1121554 = r1121538 * r1121553;
        double r1121555 = fma(r1121554, r1121540, r1121535);
        double r1121556 = r1121535 / r1121537;
        double r1121557 = r1121539 / r1121537;
        double r1121558 = r1121556 - r1121557;
        double r1121559 = r1121536 * r1121558;
        double r1121560 = r1121559 + r1121539;
        double r1121561 = r1121551 ? r1121555 : r1121560;
        return r1121561;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.7
Target12.6
Herbie8.6
\[\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 (+ x (/ (* (- y z) (- t x)) (- a z))) < -1.0345672052037073e-307 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.6

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

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

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

    if -1.0345672052037073e-307 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 61.2

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

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

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

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

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

Reproduce

herbie shell --seed 2019235 +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.25361310560950359e188) (- t (* (/ y z) (- t x))) (if (< z 4.44670236911381103e64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

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