Average Error: 24.8 → 12.5
Time: 5.9s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.0538724122977772 \cdot 10^{187} \lor \neg \left(z \le 2.80403393809698577 \cdot 10^{31}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - x}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}, \frac{y - z}{\sqrt[3]{a - z}}, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -1.0538724122977772 \cdot 10^{187} \lor \neg \left(z \le 2.80403393809698577 \cdot 10^{31}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - x}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}, \frac{y - z}{\sqrt[3]{a - z}}, x\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r627411 = x;
        double r627412 = y;
        double r627413 = z;
        double r627414 = r627412 - r627413;
        double r627415 = t;
        double r627416 = r627415 - r627411;
        double r627417 = r627414 * r627416;
        double r627418 = a;
        double r627419 = r627418 - r627413;
        double r627420 = r627417 / r627419;
        double r627421 = r627411 + r627420;
        return r627421;
}

double f(double x, double y, double z, double t, double a) {
        double r627422 = z;
        double r627423 = -1.0538724122977772e+187;
        bool r627424 = r627422 <= r627423;
        double r627425 = 2.8040339380969858e+31;
        bool r627426 = r627422 <= r627425;
        double r627427 = !r627426;
        bool r627428 = r627424 || r627427;
        double r627429 = y;
        double r627430 = x;
        double r627431 = r627430 / r627422;
        double r627432 = t;
        double r627433 = r627432 / r627422;
        double r627434 = r627431 - r627433;
        double r627435 = fma(r627429, r627434, r627432);
        double r627436 = r627432 - r627430;
        double r627437 = a;
        double r627438 = r627437 - r627422;
        double r627439 = cbrt(r627438);
        double r627440 = r627439 * r627439;
        double r627441 = r627436 / r627440;
        double r627442 = r627429 - r627422;
        double r627443 = r627442 / r627439;
        double r627444 = fma(r627441, r627443, r627430);
        double r627445 = r627428 ? r627435 : r627444;
        return r627445;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.8
Target12.0
Herbie12.5
\[\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 z < -1.0538724122977772e+187 or 2.8040339380969858e+31 < z

    1. Initial program 43.4

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

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

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

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

    if -1.0538724122977772e+187 < z < 2.8040339380969858e+31

    1. Initial program 14.2

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

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

      \[\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 fma-udef7.0

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

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

      \[\leadsto \left(t - x\right) \cdot \frac{y - z}{\color{blue}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}}} + x\]
    10. Applied *-un-lft-identity7.6

      \[\leadsto \left(t - x\right) \cdot \frac{\color{blue}{1 \cdot \left(y - z\right)}}{\left(\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}\right) \cdot \sqrt[3]{a - z}} + x\]
    11. Applied times-frac7.6

      \[\leadsto \left(t - x\right) \cdot \color{blue}{\left(\frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}} \cdot \frac{y - z}{\sqrt[3]{a - z}}\right)} + x\]
    12. Applied associate-*r*8.5

      \[\leadsto \color{blue}{\left(\left(t - x\right) \cdot \frac{1}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}\right) \cdot \frac{y - z}{\sqrt[3]{a - z}}} + x\]
    13. Simplified8.5

      \[\leadsto \color{blue}{\frac{t - x}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}} \cdot \frac{y - z}{\sqrt[3]{a - z}} + x\]
    14. Using strategy rm
    15. Applied fma-def8.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.0538724122977772 \cdot 10^{187} \lor \neg \left(z \le 2.80403393809698577 \cdot 10^{31}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t - x}{\sqrt[3]{a - z} \cdot \sqrt[3]{a - z}}, \frac{y - z}{\sqrt[3]{a - z}}, x\right)\\ \end{array}\]

Reproduce

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