Average Error: 23.9 → 7.6
Time: 6.2s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -2.67915527133158234 \cdot 10^{-127} \lor \neg \left(a \le 4.7846661919792587 \cdot 10^{-147}\right):\\ \;\;\;\;\frac{t}{\frac{a - z}{y - z}} - \left(\frac{x}{\frac{a - z}{y - z}} - x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -2.67915527133158234 \cdot 10^{-127} \lor \neg \left(a \le 4.7846661919792587 \cdot 10^{-147}\right):\\
\;\;\;\;\frac{t}{\frac{a - z}{y - z}} - \left(\frac{x}{\frac{a - z}{y - z}} - x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r604368 = x;
        double r604369 = y;
        double r604370 = z;
        double r604371 = r604369 - r604370;
        double r604372 = t;
        double r604373 = r604372 - r604368;
        double r604374 = r604371 * r604373;
        double r604375 = a;
        double r604376 = r604375 - r604370;
        double r604377 = r604374 / r604376;
        double r604378 = r604368 + r604377;
        return r604378;
}

double f(double x, double y, double z, double t, double a) {
        double r604379 = a;
        double r604380 = -2.6791552713315823e-127;
        bool r604381 = r604379 <= r604380;
        double r604382 = 4.7846661919792587e-147;
        bool r604383 = r604379 <= r604382;
        double r604384 = !r604383;
        bool r604385 = r604381 || r604384;
        double r604386 = t;
        double r604387 = z;
        double r604388 = r604379 - r604387;
        double r604389 = y;
        double r604390 = r604389 - r604387;
        double r604391 = r604388 / r604390;
        double r604392 = r604386 / r604391;
        double r604393 = x;
        double r604394 = r604393 / r604391;
        double r604395 = r604394 - r604393;
        double r604396 = r604392 - r604395;
        double r604397 = r604393 / r604387;
        double r604398 = r604386 / r604387;
        double r604399 = r604397 - r604398;
        double r604400 = fma(r604389, r604399, r604386);
        double r604401 = r604385 ? r604396 : r604400;
        return r604401;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.9
Target11.8
Herbie7.6
\[\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 a < -2.6791552713315823e-127 or 4.7846661919792587e-147 < a

    1. Initial program 22.6

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

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

      \[\leadsto \mathsf{fma}\left(\frac{y - z}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}}, t - x, x\right)\]
    5. Applied associate-/r*9.8

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}}{\sqrt[3]{a - z}}}, t - x, x\right)\]
    6. Using strategy rm
    7. Applied fma-udef9.8

      \[\leadsto \color{blue}{\frac{\frac{y - z}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}}{\sqrt[3]{a - z}} \cdot \left(t - x\right) + x}\]
    8. Simplified9.3

      \[\leadsto \color{blue}{\frac{t - x}{\frac{a - z}{y - z}}} + x\]
    9. Using strategy rm
    10. Applied div-sub9.3

      \[\leadsto \color{blue}{\left(\frac{t}{\frac{a - z}{y - z}} - \frac{x}{\frac{a - z}{y - z}}\right)} + x\]
    11. Applied associate-+l-6.3

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

    if -2.6791552713315823e-127 < a < 4.7846661919792587e-147

    1. Initial program 28.2

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

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

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

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

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

Reproduce

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