Average Error: 23.1 → 10.0
Time: 22.0s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.576904563487002 \cdot 10^{+105}:\\ \;\;\;\;t + \left(\frac{x}{z} - \frac{t}{z}\right) \cdot y\\ \mathbf{elif}\;z \le 2.4122683507888716 \cdot 10^{+184}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}, \frac{\sqrt[3]{t - x}}{\sqrt[3]{a - z}} \cdot \left(y - z\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;t + \left(\frac{x}{z} - \frac{t}{z}\right) \cdot y\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -4.576904563487002 \cdot 10^{+105}:\\
\;\;\;\;t + \left(\frac{x}{z} - \frac{t}{z}\right) \cdot y\\

\mathbf{elif}\;z \le 2.4122683507888716 \cdot 10^{+184}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}, \frac{\sqrt[3]{t - x}}{\sqrt[3]{a - z}} \cdot \left(y - z\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;t + \left(\frac{x}{z} - \frac{t}{z}\right) \cdot y\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r29298852 = x;
        double r29298853 = y;
        double r29298854 = z;
        double r29298855 = r29298853 - r29298854;
        double r29298856 = t;
        double r29298857 = r29298856 - r29298852;
        double r29298858 = r29298855 * r29298857;
        double r29298859 = a;
        double r29298860 = r29298859 - r29298854;
        double r29298861 = r29298858 / r29298860;
        double r29298862 = r29298852 + r29298861;
        return r29298862;
}

double f(double x, double y, double z, double t, double a) {
        double r29298863 = z;
        double r29298864 = -4.576904563487002e+105;
        bool r29298865 = r29298863 <= r29298864;
        double r29298866 = t;
        double r29298867 = x;
        double r29298868 = r29298867 / r29298863;
        double r29298869 = r29298866 / r29298863;
        double r29298870 = r29298868 - r29298869;
        double r29298871 = y;
        double r29298872 = r29298870 * r29298871;
        double r29298873 = r29298866 + r29298872;
        double r29298874 = 2.4122683507888716e+184;
        bool r29298875 = r29298863 <= r29298874;
        double r29298876 = r29298866 - r29298867;
        double r29298877 = cbrt(r29298876);
        double r29298878 = r29298877 * r29298877;
        double r29298879 = a;
        double r29298880 = r29298879 - r29298863;
        double r29298881 = cbrt(r29298880);
        double r29298882 = r29298881 * r29298881;
        double r29298883 = r29298878 / r29298882;
        double r29298884 = r29298877 / r29298881;
        double r29298885 = r29298871 - r29298863;
        double r29298886 = r29298884 * r29298885;
        double r29298887 = fma(r29298883, r29298886, r29298867);
        double r29298888 = r29298875 ? r29298887 : r29298873;
        double r29298889 = r29298865 ? r29298873 : r29298888;
        return r29298889;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.1
Target11.7
Herbie10.0
\[\begin{array}{l} \mathbf{if}\;z \lt -1.2536131056095036 \cdot 10^{+188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811 \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 z < -4.576904563487002e+105 or 2.4122683507888716e+184 < z

    1. Initial program 44.1

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

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

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

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

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

      \[\leadsto \left(t - x\right) \cdot \color{blue}{\frac{y - z}{a - z}} + x\]
    9. Taylor expanded around inf 24.7

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

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

    if -4.576904563487002e+105 < z < 2.4122683507888716e+184

    1. Initial program 14.4

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

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

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

      \[\leadsto \frac{t - x}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}} \cdot \left(y - z\right) + x\]
    7. Applied add-cube-cbrt9.9

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}\right) \cdot \sqrt[3]{t - x}}}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}} \cdot \left(y - z\right) + x\]
    8. Applied times-frac9.9

      \[\leadsto \color{blue}{\left(\frac{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{\sqrt[3]{t - x}}{\sqrt[3]{a - z}}\right)} \cdot \left(y - z\right) + x\]
    9. Applied associate-*l*7.1

      \[\leadsto \color{blue}{\frac{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \left(\frac{\sqrt[3]{t - x}}{\sqrt[3]{a - z}} \cdot \left(y - z\right)\right)} + x\]
    10. Using strategy rm
    11. Applied fma-def7.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.576904563487002 \cdot 10^{+105}:\\ \;\;\;\;t + \left(\frac{x}{z} - \frac{t}{z}\right) \cdot y\\ \mathbf{elif}\;z \le 2.4122683507888716 \cdot 10^{+184}:\\ \;\;\;\;\mathsf{fma}\left(\frac{\sqrt[3]{t - x} \cdot \sqrt[3]{t - x}}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}, \frac{\sqrt[3]{t - x}}{\sqrt[3]{a - z}} \cdot \left(y - z\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;t + \left(\frac{x}{z} - \frac{t}{z}\right) \cdot y\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"

  :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))))