Average Error: 24.4 → 8.3
Time: 28.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 -1.325586496596394733118592144672022611 \cdot 10^{-299} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\ \;\;\;\;\mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{a - z}, t - x, 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}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -1.325586496596394733118592144672022611 \cdot 10^{-299} \lor \neg \left(x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0\right):\\
\;\;\;\;\mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{a - z}, t - x, 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 r499881 = x;
        double r499882 = y;
        double r499883 = z;
        double r499884 = r499882 - r499883;
        double r499885 = t;
        double r499886 = r499885 - r499881;
        double r499887 = r499884 * r499886;
        double r499888 = a;
        double r499889 = r499888 - r499883;
        double r499890 = r499887 / r499889;
        double r499891 = r499881 + r499890;
        return r499891;
}

double f(double x, double y, double z, double t, double a) {
        double r499892 = x;
        double r499893 = y;
        double r499894 = z;
        double r499895 = r499893 - r499894;
        double r499896 = t;
        double r499897 = r499896 - r499892;
        double r499898 = r499895 * r499897;
        double r499899 = a;
        double r499900 = r499899 - r499894;
        double r499901 = r499898 / r499900;
        double r499902 = r499892 + r499901;
        double r499903 = -1.3255864965963947e-299;
        bool r499904 = r499902 <= r499903;
        double r499905 = 0.0;
        bool r499906 = r499902 <= r499905;
        double r499907 = !r499906;
        bool r499908 = r499904 || r499907;
        double r499909 = 1.0;
        double r499910 = r499909 / r499900;
        double r499911 = r499895 * r499910;
        double r499912 = fma(r499911, r499897, r499892);
        double r499913 = r499892 / r499894;
        double r499914 = r499896 / r499894;
        double r499915 = r499913 - r499914;
        double r499916 = fma(r499893, r499915, r499896);
        double r499917 = r499908 ? r499912 : r499916;
        return r499917;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.4
Target11.6
Herbie8.3
\[\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))) < -1.3255864965963947e-299 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.0

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

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

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

    if -1.3255864965963947e-299 < (+ 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. Using strategy rm
    4. Applied div-inv60.7

      \[\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 add-cube-cbrt60.5

      \[\leadsto \mathsf{fma}\left(\left(y - z\right) \cdot \frac{1}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}}, t - x, x\right)\]
    7. Applied add-sqr-sqrt60.5

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

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

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

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

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

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

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

Reproduce

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