Average Error: 24.2 → 8.8
Time: 17.6s
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 -4.82516022252417878 \cdot 10^{-304} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{\frac{1}{a - z}}{\frac{1}{y - 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 -4.82516022252417878 \cdot 10^{-304} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{1}{a - z}}{\frac{1}{y - 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 r784394 = x;
        double r784395 = y;
        double r784396 = z;
        double r784397 = r784395 - r784396;
        double r784398 = t;
        double r784399 = r784398 - r784394;
        double r784400 = r784397 * r784399;
        double r784401 = a;
        double r784402 = r784401 - r784396;
        double r784403 = r784400 / r784402;
        double r784404 = r784394 + r784403;
        return r784404;
}

double f(double x, double y, double z, double t, double a) {
        double r784405 = x;
        double r784406 = y;
        double r784407 = z;
        double r784408 = r784406 - r784407;
        double r784409 = t;
        double r784410 = r784409 - r784405;
        double r784411 = r784408 * r784410;
        double r784412 = a;
        double r784413 = r784412 - r784407;
        double r784414 = r784411 / r784413;
        double r784415 = r784405 + r784414;
        double r784416 = -4.825160222524179e-304;
        bool r784417 = r784415 <= r784416;
        double r784418 = 0.0;
        bool r784419 = r784415 <= r784418;
        double r784420 = !r784419;
        bool r784421 = r784417 || r784420;
        double r784422 = 1.0;
        double r784423 = r784422 / r784413;
        double r784424 = r784422 / r784408;
        double r784425 = r784423 / r784424;
        double r784426 = fma(r784425, r784410, r784405);
        double r784427 = r784406 / r784407;
        double r784428 = r784427 * r784410;
        double r784429 = r784409 - r784428;
        double r784430 = r784421 ? r784426 : r784429;
        return r784430;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.2
Target11.7
Herbie8.8
\[\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))) < -4.825160222524179e-304 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 20.9

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{\color{blue}{\left(a - z\right) \cdot \frac{1}{y - z}}}, t - x, x\right)\]
    7. Using strategy rm
    8. Applied associate-/r*7.8

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

    if -4.825160222524179e-304 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 60.8

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

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

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

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

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

Reproduce

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