Average Error: 24.2 → 8.1
Time: 16.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 -5.200374814832920856809590955125876331591 \cdot 10^{-308} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{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 -5.200374814832920856809590955125876331591 \cdot 10^{-308} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{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 r835990 = x;
        double r835991 = y;
        double r835992 = z;
        double r835993 = r835991 - r835992;
        double r835994 = t;
        double r835995 = r835994 - r835990;
        double r835996 = r835993 * r835995;
        double r835997 = a;
        double r835998 = r835997 - r835992;
        double r835999 = r835996 / r835998;
        double r836000 = r835990 + r835999;
        return r836000;
}

double f(double x, double y, double z, double t, double a) {
        double r836001 = x;
        double r836002 = y;
        double r836003 = z;
        double r836004 = r836002 - r836003;
        double r836005 = t;
        double r836006 = r836005 - r836001;
        double r836007 = r836004 * r836006;
        double r836008 = a;
        double r836009 = r836008 - r836003;
        double r836010 = r836007 / r836009;
        double r836011 = r836001 + r836010;
        double r836012 = -5.200374814832921e-308;
        bool r836013 = r836011 <= r836012;
        double r836014 = 0.0;
        bool r836015 = r836011 <= r836014;
        double r836016 = !r836015;
        bool r836017 = r836013 || r836016;
        double r836018 = r836004 / r836009;
        double r836019 = fma(r836018, r836006, r836001);
        double r836020 = r836002 / r836003;
        double r836021 = r836020 * r836006;
        double r836022 = r836005 - r836021;
        double r836023 = r836017 ? r836019 : r836022;
        return r836023;
}

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.9
Herbie8.1
\[\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))) < -5.200374814832921e-308 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 20.8

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

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

      \[\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 pow17.2

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y - z\right)}^{1}} \cdot {\left(\frac{1}{a - z}\right)}^{1}, t - x, x\right)\]
    8. Applied pow-prod-down7.2

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

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

    if -5.200374814832921e-308 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 61.3

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

      \[\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.4

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

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

Reproduce

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