Average Error: 24.3 → 9.5
Time: 32.4s
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):\\ \;\;\;\;t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right) + \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):\\
\;\;\;\;t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right) + \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 r332903 = x;
        double r332904 = y;
        double r332905 = z;
        double r332906 = r332904 - r332905;
        double r332907 = t;
        double r332908 = r332907 - r332903;
        double r332909 = r332906 * r332908;
        double r332910 = a;
        double r332911 = r332910 - r332905;
        double r332912 = r332909 / r332911;
        double r332913 = r332903 + r332912;
        return r332913;
}

double f(double x, double y, double z, double t, double a) {
        double r332914 = a;
        double r332915 = -6.14323213192593e-28;
        bool r332916 = r332914 <= r332915;
        double r332917 = 5.347427363587528e-182;
        bool r332918 = r332914 <= r332917;
        double r332919 = !r332918;
        bool r332920 = r332916 || r332919;
        double r332921 = t;
        double r332922 = y;
        double r332923 = z;
        double r332924 = r332914 - r332923;
        double r332925 = r332922 / r332924;
        double r332926 = r332923 / r332924;
        double r332927 = r332925 - r332926;
        double r332928 = r332921 * r332927;
        double r332929 = x;
        double r332930 = -r332929;
        double r332931 = 1.0;
        double r332932 = cbrt(r332924);
        double r332933 = r332932 * r332932;
        double r332934 = r332931 / r332933;
        double r332935 = r332923 / r332932;
        double r332936 = r332934 * r332935;
        double r332937 = r332925 - r332936;
        double r332938 = fma(r332930, r332937, r332929);
        double r332939 = r332928 + r332938;
        double r332940 = r332922 / r332923;
        double r332941 = r332921 - r332929;
        double r332942 = r332940 * r332941;
        double r332943 = r332921 - r332942;
        double r332944 = r332920 ? r332939 : r332943;
        return r332944;
}

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-rgt-in8.8

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

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

      \[\leadsto t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right) + \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 t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right) + \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 t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right) + \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 t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right) + \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):\\ \;\;\;\;t \cdot \left(\frac{y}{a - z} - \frac{z}{a - z}\right) + \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))))