Average Error: 24.7 → 10.0
Time: 28.2s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -4.046536476058793676946234371999781019952 \cdot 10^{-154} \lor \neg \left(a \le 7.692781660197598904440558192035913736358 \cdot 10^{-150}\right):\\ \;\;\;\;\frac{t - x}{\left(a - z\right) \cdot \frac{1}{y - z}} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, t - \frac{t \cdot y}{z}\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -4.046536476058793676946234371999781019952 \cdot 10^{-154} \lor \neg \left(a \le 7.692781660197598904440558192035913736358 \cdot 10^{-150}\right):\\
\;\;\;\;\frac{t - x}{\left(a - z\right) \cdot \frac{1}{y - z}} + x\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r485369 = x;
        double r485370 = y;
        double r485371 = z;
        double r485372 = r485370 - r485371;
        double r485373 = t;
        double r485374 = r485373 - r485369;
        double r485375 = r485372 * r485374;
        double r485376 = a;
        double r485377 = r485376 - r485371;
        double r485378 = r485375 / r485377;
        double r485379 = r485369 + r485378;
        return r485379;
}

double f(double x, double y, double z, double t, double a) {
        double r485380 = a;
        double r485381 = -4.046536476058794e-154;
        bool r485382 = r485380 <= r485381;
        double r485383 = 7.692781660197599e-150;
        bool r485384 = r485380 <= r485383;
        double r485385 = !r485384;
        bool r485386 = r485382 || r485385;
        double r485387 = t;
        double r485388 = x;
        double r485389 = r485387 - r485388;
        double r485390 = z;
        double r485391 = r485380 - r485390;
        double r485392 = 1.0;
        double r485393 = y;
        double r485394 = r485393 - r485390;
        double r485395 = r485392 / r485394;
        double r485396 = r485391 * r485395;
        double r485397 = r485389 / r485396;
        double r485398 = r485397 + r485388;
        double r485399 = r485388 / r485390;
        double r485400 = r485387 * r485393;
        double r485401 = r485400 / r485390;
        double r485402 = r485387 - r485401;
        double r485403 = fma(r485399, r485393, r485402);
        double r485404 = r485386 ? r485398 : r485403;
        return r485404;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.7
Target11.9
Herbie10.0
\[\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 a < -4.046536476058794e-154 or 7.692781660197599e-150 < a

    1. Initial program 23.1

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right) + x}\]
    7. Simplified9.2

      \[\leadsto \color{blue}{\frac{t - x}{\frac{a - z}{y - z}}} + x\]
    8. Using strategy rm
    9. Applied div-inv9.2

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

    if -4.046536476058794e-154 < a < 7.692781660197599e-150

    1. Initial program 30.2

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

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

      \[\leadsto \color{blue}{\frac{y - z}{a - z} \cdot \left(t - x\right) + x}\]
    5. Taylor expanded around inf 12.6

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

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

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

Reproduce

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