Average Error: 24.1 → 9.3
Time: 6.7s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.94196112306639759 \cdot 10^{-54} \lor \neg \left(a \le 4.30885620514935567 \cdot 10^{-74}\right):\\ \;\;\;\;\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{1} \cdot \left(\frac{\sqrt[3]{y - z}}{a - z} \cdot t\right) + \mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{y - z}{a - z} \cdot t + \frac{x \cdot y}{z}\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -1.94196112306639759 \cdot 10^{-54} \lor \neg \left(a \le 4.30885620514935567 \cdot 10^{-74}\right):\\
\;\;\;\;\frac{\sqrt[3]{y - z} \cdot \sqrt[3]{y - z}}{1} \cdot \left(\frac{\sqrt[3]{y - z}}{a - z} \cdot t\right) + \mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{y - z}{a - z} \cdot t + \frac{x \cdot y}{z}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r605725 = x;
        double r605726 = y;
        double r605727 = z;
        double r605728 = r605726 - r605727;
        double r605729 = t;
        double r605730 = r605729 - r605725;
        double r605731 = r605728 * r605730;
        double r605732 = a;
        double r605733 = r605732 - r605727;
        double r605734 = r605731 / r605733;
        double r605735 = r605725 + r605734;
        return r605735;
}

double f(double x, double y, double z, double t, double a) {
        double r605736 = a;
        double r605737 = -1.9419611230663976e-54;
        bool r605738 = r605736 <= r605737;
        double r605739 = 4.308856205149356e-74;
        bool r605740 = r605736 <= r605739;
        double r605741 = !r605740;
        bool r605742 = r605738 || r605741;
        double r605743 = y;
        double r605744 = z;
        double r605745 = r605743 - r605744;
        double r605746 = cbrt(r605745);
        double r605747 = r605746 * r605746;
        double r605748 = 1.0;
        double r605749 = r605747 / r605748;
        double r605750 = r605736 - r605744;
        double r605751 = r605746 / r605750;
        double r605752 = t;
        double r605753 = r605751 * r605752;
        double r605754 = r605749 * r605753;
        double r605755 = x;
        double r605756 = -r605755;
        double r605757 = r605745 / r605750;
        double r605758 = fma(r605756, r605757, r605755);
        double r605759 = r605754 + r605758;
        double r605760 = r605757 * r605752;
        double r605761 = r605755 * r605743;
        double r605762 = r605761 / r605744;
        double r605763 = r605760 + r605762;
        double r605764 = r605742 ? r605759 : r605763;
        return r605764;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.1
Target12.2
Herbie9.3
\[\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 < -1.9419611230663976e-54 or 4.308856205149356e-74 < a

    1. Initial program 21.7

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

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

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

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

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot t + \color{blue}{\mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity5.4

      \[\leadsto \frac{y - z}{\color{blue}{1 \cdot \left(a - z\right)}} \cdot t + \mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)\]
    12. Applied add-cube-cbrt5.9

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

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

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

    if -1.9419611230663976e-54 < a < 4.308856205149356e-74

    1. Initial program 28.4

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

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

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

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

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

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot t + \color{blue}{\frac{x \cdot y}{z}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification9.3

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

Reproduce

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