Average Error: 24.2 → 9.5
Time: 28.5s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -8.723377186558466195489290365443680381262 \cdot 10^{-142}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y}} - \frac{z}{a - z}, t - x, x\right)\\ \mathbf{elif}\;a \le 4.615972332582289948571164052641850551165 \cdot 10^{-128} \lor \neg \left(a \le 1.473461382813240831879178951903024277301 \cdot 10^{-34}\right) \land a \le 5.014542708980201603462177851008212473016 \cdot 10^{-12}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} - \frac{1}{\left(a - z\right) \cdot \frac{1}{z}}, t - x, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;a \le -8.723377186558466195489290365443680381262 \cdot 10^{-142}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y}} - \frac{z}{a - z}, t - x, x\right)\\

\mathbf{elif}\;a \le 4.615972332582289948571164052641850551165 \cdot 10^{-128} \lor \neg \left(a \le 1.473461382813240831879178951903024277301 \cdot 10^{-34}\right) \land a \le 5.014542708980201603462177851008212473016 \cdot 10^{-12}:\\
\;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r417927 = x;
        double r417928 = y;
        double r417929 = z;
        double r417930 = r417928 - r417929;
        double r417931 = t;
        double r417932 = r417931 - r417927;
        double r417933 = r417930 * r417932;
        double r417934 = a;
        double r417935 = r417934 - r417929;
        double r417936 = r417933 / r417935;
        double r417937 = r417927 + r417936;
        return r417937;
}

double f(double x, double y, double z, double t, double a) {
        double r417938 = a;
        double r417939 = -8.723377186558466e-142;
        bool r417940 = r417938 <= r417939;
        double r417941 = 1.0;
        double r417942 = z;
        double r417943 = r417938 - r417942;
        double r417944 = y;
        double r417945 = r417943 / r417944;
        double r417946 = r417941 / r417945;
        double r417947 = r417942 / r417943;
        double r417948 = r417946 - r417947;
        double r417949 = t;
        double r417950 = x;
        double r417951 = r417949 - r417950;
        double r417952 = fma(r417948, r417951, r417950);
        double r417953 = 4.61597233258229e-128;
        bool r417954 = r417938 <= r417953;
        double r417955 = 1.4734613828132408e-34;
        bool r417956 = r417938 <= r417955;
        double r417957 = !r417956;
        double r417958 = 5.014542708980202e-12;
        bool r417959 = r417938 <= r417958;
        bool r417960 = r417957 && r417959;
        bool r417961 = r417954 || r417960;
        double r417962 = r417944 / r417942;
        double r417963 = r417962 * r417951;
        double r417964 = r417949 - r417963;
        double r417965 = r417944 / r417943;
        double r417966 = r417941 / r417942;
        double r417967 = r417943 * r417966;
        double r417968 = r417941 / r417967;
        double r417969 = r417965 - r417968;
        double r417970 = fma(r417969, r417951, r417950);
        double r417971 = r417961 ? r417964 : r417970;
        double r417972 = r417940 ? r417952 : r417971;
        return r417972;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.2
Target11.9
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 3 regimes
  2. if a < -8.723377186558466e-142

    1. Initial program 24.0

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

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

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

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

    if -8.723377186558466e-142 < a < 4.61597233258229e-128 or 1.4734613828132408e-34 < a < 5.014542708980202e-12

    1. Initial program 28.1

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

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

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

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

    if 4.61597233258229e-128 < a < 1.4734613828132408e-34 or 5.014542708980202e-12 < a

    1. Initial program 21.6

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -8.723377186558466195489290365443680381262 \cdot 10^{-142}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{a - z}{y}} - \frac{z}{a - z}, t - x, x\right)\\ \mathbf{elif}\;a \le 4.615972332582289948571164052641850551165 \cdot 10^{-128} \lor \neg \left(a \le 1.473461382813240831879178951903024277301 \cdot 10^{-34}\right) \land a \le 5.014542708980201603462177851008212473016 \cdot 10^{-12}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y}{a - z} - \frac{1}{\left(a - z\right) \cdot \frac{1}{z}}, t - x, x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019304 +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.25361310560950359e188) (- t (* (/ y z) (- t x))) (if (< z 4.44670236911381103e64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

  (+ x (/ (* (- y z) (- t x)) (- a z))))