Average Error: 24.2 → 9.0
Time: 14.0s
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}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - z} \cdot \left(y - z\right), t - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\left(a - z\right) \cdot \frac{1}{y - z}}, t - x, 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}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{a - z} \cdot \left(y - z\right), t - x, x\right)\\

\mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\
\;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r577626 = x;
        double r577627 = y;
        double r577628 = z;
        double r577629 = r577627 - r577628;
        double r577630 = t;
        double r577631 = r577630 - r577626;
        double r577632 = r577629 * r577631;
        double r577633 = a;
        double r577634 = r577633 - r577628;
        double r577635 = r577632 / r577634;
        double r577636 = r577626 + r577635;
        return r577636;
}

double f(double x, double y, double z, double t, double a) {
        double r577637 = x;
        double r577638 = y;
        double r577639 = z;
        double r577640 = r577638 - r577639;
        double r577641 = t;
        double r577642 = r577641 - r577637;
        double r577643 = r577640 * r577642;
        double r577644 = a;
        double r577645 = r577644 - r577639;
        double r577646 = r577643 / r577645;
        double r577647 = r577637 + r577646;
        double r577648 = -4.825160222524179e-304;
        bool r577649 = r577647 <= r577648;
        double r577650 = 1.0;
        double r577651 = r577650 / r577645;
        double r577652 = r577651 * r577640;
        double r577653 = fma(r577652, r577642, r577637);
        double r577654 = 0.0;
        bool r577655 = r577647 <= r577654;
        double r577656 = r577637 / r577639;
        double r577657 = r577641 / r577639;
        double r577658 = r577656 - r577657;
        double r577659 = r577638 * r577658;
        double r577660 = r577641 + r577659;
        double r577661 = r577650 / r577640;
        double r577662 = r577645 * r577661;
        double r577663 = r577650 / r577662;
        double r577664 = fma(r577663, r577642, r577637);
        double r577665 = r577655 ? r577660 : r577664;
        double r577666 = r577649 ? r577653 : r577665;
        return r577666;
}

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
Herbie9.0
\[\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 3 regimes
  2. if (+ x (/ (* (- y z) (- t x)) (- a z))) < -4.825160222524179e-304

    1. Initial program 21.1

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

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

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

      \[\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 add-cube-cbrt8.0

      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(a - z\right) \cdot \frac{1}{y - z}}, t - x, x\right)\]
    9. Applied times-frac8.0

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{a - z} \cdot \frac{\sqrt[3]{1}}{\frac{1}{y - z}}}, t - x, x\right)\]
    10. Simplified8.0

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{a - z} \cdot \color{blue}{\left(y - z\right)}, 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. Simplified21.7

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

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

    1. Initial program 20.7

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

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

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

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

    \[\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}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - z} \cdot \left(y - z\right), t - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\left(a - z\right) \cdot \frac{1}{y - z}}, t - x, 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))))