Average Error: 24.6 → 8.5
Time: 18.8s
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.24126254442958129 \cdot 10^{-270} \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}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\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 -1.24126254442958129 \cdot 10^{-270} \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}:\\
\;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r723434 = x;
        double r723435 = y;
        double r723436 = z;
        double r723437 = r723435 - r723436;
        double r723438 = t;
        double r723439 = r723438 - r723434;
        double r723440 = r723437 * r723439;
        double r723441 = a;
        double r723442 = r723441 - r723436;
        double r723443 = r723440 / r723442;
        double r723444 = r723434 + r723443;
        return r723444;
}

double f(double x, double y, double z, double t, double a) {
        double r723445 = x;
        double r723446 = y;
        double r723447 = z;
        double r723448 = r723446 - r723447;
        double r723449 = t;
        double r723450 = r723449 - r723445;
        double r723451 = r723448 * r723450;
        double r723452 = a;
        double r723453 = r723452 - r723447;
        double r723454 = r723451 / r723453;
        double r723455 = r723445 + r723454;
        double r723456 = -1.2412625444295813e-270;
        bool r723457 = r723455 <= r723456;
        double r723458 = 0.0;
        bool r723459 = r723455 <= r723458;
        double r723460 = !r723459;
        bool r723461 = r723457 || r723460;
        double r723462 = 1.0;
        double r723463 = r723462 / r723453;
        double r723464 = r723448 * r723463;
        double r723465 = fma(r723464, r723450, r723445);
        double r723466 = r723446 / r723447;
        double r723467 = r723466 * r723450;
        double r723468 = r723449 - r723467;
        double r723469 = r723461 ? r723465 : r723468;
        return r723469;
}

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.3
Herbie8.5
\[\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))) < -1.2412625444295813e-270 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.1

      \[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)\]

    if -1.2412625444295813e-270 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 58.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -1.24126254442958129 \cdot 10^{-270} \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}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array}\]

Reproduce

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