Average Error: 24.3 → 9.5
Time: 28.1s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -6.143232131925929682871142551410290774749 \cdot 10^{-28} \lor \neg \left(a \le 5.347427363587527749751148009426342589484 \cdot 10^{-182}\right):\\ \;\;\;\;\left(\frac{y}{a - z} - \frac{z}{a - z}\right) \cdot t + \mathsf{fma}\left(-x, \frac{y}{a - z} - \frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{z}{\sqrt[3]{a - z}}, 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}\;a \le -6.143232131925929682871142551410290774749 \cdot 10^{-28} \lor \neg \left(a \le 5.347427363587527749751148009426342589484 \cdot 10^{-182}\right):\\
\;\;\;\;\left(\frac{y}{a - z} - \frac{z}{a - z}\right) \cdot t + \mathsf{fma}\left(-x, \frac{y}{a - z} - \frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{z}{\sqrt[3]{a - z}}, 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 r457934 = x;
        double r457935 = y;
        double r457936 = z;
        double r457937 = r457935 - r457936;
        double r457938 = t;
        double r457939 = r457938 - r457934;
        double r457940 = r457937 * r457939;
        double r457941 = a;
        double r457942 = r457941 - r457936;
        double r457943 = r457940 / r457942;
        double r457944 = r457934 + r457943;
        return r457944;
}

double f(double x, double y, double z, double t, double a) {
        double r457945 = a;
        double r457946 = -6.14323213192593e-28;
        bool r457947 = r457945 <= r457946;
        double r457948 = 5.347427363587528e-182;
        bool r457949 = r457945 <= r457948;
        double r457950 = !r457949;
        bool r457951 = r457947 || r457950;
        double r457952 = y;
        double r457953 = z;
        double r457954 = r457945 - r457953;
        double r457955 = r457952 / r457954;
        double r457956 = r457953 / r457954;
        double r457957 = r457955 - r457956;
        double r457958 = t;
        double r457959 = r457957 * r457958;
        double r457960 = x;
        double r457961 = -r457960;
        double r457962 = 1.0;
        double r457963 = cbrt(r457954);
        double r457964 = r457963 * r457963;
        double r457965 = r457962 / r457964;
        double r457966 = r457953 / r457963;
        double r457967 = r457965 * r457966;
        double r457968 = r457955 - r457967;
        double r457969 = fma(r457961, r457968, r457960);
        double r457970 = r457959 + r457969;
        double r457971 = r457952 / r457953;
        double r457972 = r457958 - r457960;
        double r457973 = r457971 * r457972;
        double r457974 = r457958 - r457973;
        double r457975 = r457951 ? r457970 : r457974;
        return r457975;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.3
Target11.7
Herbie9.5
\[\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 < -6.14323213192593e-28 or 5.347427363587528e-182 < a

    1. Initial program 22.9

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

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

      \[\leadsto \color{blue}{\frac{y - z}{a - z} \cdot \left(t - x\right) + x}\]
    5. Using strategy rm
    6. Applied div-sub8.8

      \[\leadsto \color{blue}{\left(\frac{y}{a - z} - \frac{z}{a - z}\right)} \cdot \left(t - x\right) + x\]
    7. Using strategy rm
    8. Applied sub-neg8.8

      \[\leadsto \left(\frac{y}{a - z} - \frac{z}{a - z}\right) \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    9. Applied distribute-lft-in8.8

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

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

      \[\leadsto \left(\frac{y}{a - z} - \frac{z}{a - z}\right) \cdot t + \color{blue}{\mathsf{fma}\left(-x, \frac{y}{a - z} - \frac{z}{a - z}, x\right)}\]
    12. Using strategy rm
    13. Applied add-cube-cbrt8.3

      \[\leadsto \left(\frac{y}{a - z} - \frac{z}{a - z}\right) \cdot t + \mathsf{fma}\left(-x, \frac{y}{a - z} - \frac{z}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}}, x\right)\]
    14. Applied *-un-lft-identity8.3

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

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

    if -6.14323213192593e-28 < a < 5.347427363587528e-182

    1. Initial program 27.7

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

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

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

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

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

Reproduce

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