Average Error: 23.9 → 9.9
Time: 22.0s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -1.00328380395392006770485157406045731932 \cdot 10^{-150}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{elif}\;a \le 1.799703930478674580109035824968453325643 \cdot 10^{-109}:\\ \;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -1.00328380395392006770485157406045731932 \cdot 10^{-150}:\\
\;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\

\mathbf{elif}\;a \le 1.799703930478674580109035824968453325643 \cdot 10^{-109}:\\
\;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r23908868 = x;
        double r23908869 = y;
        double r23908870 = z;
        double r23908871 = r23908869 - r23908870;
        double r23908872 = t;
        double r23908873 = r23908872 - r23908868;
        double r23908874 = r23908871 * r23908873;
        double r23908875 = a;
        double r23908876 = r23908875 - r23908870;
        double r23908877 = r23908874 / r23908876;
        double r23908878 = r23908868 + r23908877;
        return r23908878;
}

double f(double x, double y, double z, double t, double a) {
        double r23908879 = a;
        double r23908880 = -1.00328380395392e-150;
        bool r23908881 = r23908879 <= r23908880;
        double r23908882 = x;
        double r23908883 = y;
        double r23908884 = z;
        double r23908885 = r23908883 - r23908884;
        double r23908886 = r23908879 - r23908884;
        double r23908887 = t;
        double r23908888 = r23908887 - r23908882;
        double r23908889 = r23908886 / r23908888;
        double r23908890 = r23908885 / r23908889;
        double r23908891 = r23908882 + r23908890;
        double r23908892 = 1.7997039304786746e-109;
        bool r23908893 = r23908879 <= r23908892;
        double r23908894 = r23908882 / r23908884;
        double r23908895 = r23908887 / r23908884;
        double r23908896 = r23908894 - r23908895;
        double r23908897 = r23908883 * r23908896;
        double r23908898 = r23908897 + r23908887;
        double r23908899 = r23908885 / r23908886;
        double r23908900 = fma(r23908888, r23908899, r23908882);
        double r23908901 = r23908893 ? r23908898 : r23908900;
        double r23908902 = r23908881 ? r23908891 : r23908901;
        return r23908902;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.9
Target11.6
Herbie9.9
\[\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 3 regimes
  2. if a < -1.00328380395392e-150

    1. Initial program 22.8

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

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

      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(t - x\right) \cdot \frac{1}{a - z}}, y - z, x\right)\]
    5. Using strategy rm
    6. Applied fma-udef11.0

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

      \[\leadsto \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}} + x\]

    if -1.00328380395392e-150 < a < 1.7997039304786746e-109

    1. Initial program 28.3

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

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

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

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

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

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

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

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

    if 1.7997039304786746e-109 < a

    1. Initial program 21.9

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -1.00328380395392006770485157406045731932 \cdot 10^{-150}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{elif}\;a \le 1.799703930478674580109035824968453325643 \cdot 10^{-109}:\\ \;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)\\ \end{array}\]

Reproduce

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