Average Error: 24.8 → 7.3
Time: 54.6s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} = -\infty:\\ \;\;\;\;\frac{y}{\frac{a - z}{t - x}} - \left(\frac{z}{\frac{a - z}{t - x}} - x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -2.614310798513736039860826911543599990161 \cdot 10^{-148}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -1.533543267934166183549967405153551686617 \cdot 10^{-301}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, t\right) - y \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - 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}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} = -\infty:\\
\;\;\;\;\frac{y}{\frac{a - z}{t - x}} - \left(\frac{z}{\frac{a - z}{t - x}} - x\right)\\

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

\mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -1.533543267934166183549967405153551686617 \cdot 10^{-301}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\

\mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, t\right) - y \cdot \frac{t}{z}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r30753027 = x;
        double r30753028 = y;
        double r30753029 = z;
        double r30753030 = r30753028 - r30753029;
        double r30753031 = t;
        double r30753032 = r30753031 - r30753027;
        double r30753033 = r30753030 * r30753032;
        double r30753034 = a;
        double r30753035 = r30753034 - r30753029;
        double r30753036 = r30753033 / r30753035;
        double r30753037 = r30753027 + r30753036;
        return r30753037;
}

double f(double x, double y, double z, double t, double a) {
        double r30753038 = x;
        double r30753039 = y;
        double r30753040 = z;
        double r30753041 = r30753039 - r30753040;
        double r30753042 = t;
        double r30753043 = r30753042 - r30753038;
        double r30753044 = r30753041 * r30753043;
        double r30753045 = a;
        double r30753046 = r30753045 - r30753040;
        double r30753047 = r30753044 / r30753046;
        double r30753048 = r30753038 + r30753047;
        double r30753049 = -inf.0;
        bool r30753050 = r30753048 <= r30753049;
        double r30753051 = r30753046 / r30753043;
        double r30753052 = r30753039 / r30753051;
        double r30753053 = r30753040 / r30753051;
        double r30753054 = r30753053 - r30753038;
        double r30753055 = r30753052 - r30753054;
        double r30753056 = -2.614310798513736e-148;
        bool r30753057 = r30753048 <= r30753056;
        double r30753058 = -1.5335432679341662e-301;
        bool r30753059 = r30753048 <= r30753058;
        double r30753060 = r30753041 / r30753046;
        double r30753061 = fma(r30753060, r30753043, r30753038);
        double r30753062 = 0.0;
        bool r30753063 = r30753048 <= r30753062;
        double r30753064 = r30753038 / r30753040;
        double r30753065 = fma(r30753064, r30753039, r30753042);
        double r30753066 = r30753042 / r30753040;
        double r30753067 = r30753039 * r30753066;
        double r30753068 = r30753065 - r30753067;
        double r30753069 = r30753063 ? r30753068 : r30753061;
        double r30753070 = r30753059 ? r30753061 : r30753069;
        double r30753071 = r30753057 ? r30753048 : r30753070;
        double r30753072 = r30753050 ? r30753055 : r30753071;
        return r30753072;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.8
Target11.8
Herbie7.3
\[\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 4 regimes
  2. if (+ x (/ (* (- y z) (- t x)) (- a z))) < -inf.0

    1. Initial program 64.0

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}} + x\]
    8. Using strategy rm
    9. Applied div-sub17.4

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

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

    if -inf.0 < (+ x (/ (* (- y z) (- t x)) (- a z))) < -2.614310798513736e-148

    1. Initial program 1.4

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

    if -2.614310798513736e-148 < (+ x (/ (* (- y z) (- t x)) (- a z))) < -1.5335432679341662e-301 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 20.6

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}} + x\]
    8. Using strategy rm
    9. Applied associate-/r/6.9

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

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

    if -1.5335432679341662e-301 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 60.6

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

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

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

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

      \[\leadsto \color{blue}{\frac{y - z}{\frac{a - z}{t - x}}} + x\]
    8. Taylor expanded around inf 17.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} = -\infty:\\ \;\;\;\;\frac{y}{\frac{a - z}{t - x}} - \left(\frac{z}{\frac{a - z}{t - x}} - x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -2.614310798513736039860826911543599990161 \cdot 10^{-148}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le -1.533543267934166183549967405153551686617 \cdot 10^{-301}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\ \mathbf{elif}\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \le 0.0:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y, t\right) - y \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\ \end{array}\]

Reproduce

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