Average Error: 24.6 → 10.1
Time: 6.8s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.40613785605337445 \cdot 10^{174} \lor \neg \left(z \le 4.166554550604968 \cdot 10^{139}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y - z\right) \cdot \frac{1}{a - z}\right) \cdot \left(t - x\right) + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -3.40613785605337445 \cdot 10^{174} \lor \neg \left(z \le 4.166554550604968 \cdot 10^{139}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r537202 = x;
        double r537203 = y;
        double r537204 = z;
        double r537205 = r537203 - r537204;
        double r537206 = t;
        double r537207 = r537206 - r537202;
        double r537208 = r537205 * r537207;
        double r537209 = a;
        double r537210 = r537209 - r537204;
        double r537211 = r537208 / r537210;
        double r537212 = r537202 + r537211;
        return r537212;
}

double f(double x, double y, double z, double t, double a) {
        double r537213 = z;
        double r537214 = -3.4061378560533744e+174;
        bool r537215 = r537213 <= r537214;
        double r537216 = 4.166554550604968e+139;
        bool r537217 = r537213 <= r537216;
        double r537218 = !r537217;
        bool r537219 = r537215 || r537218;
        double r537220 = y;
        double r537221 = x;
        double r537222 = r537221 / r537213;
        double r537223 = t;
        double r537224 = r537223 / r537213;
        double r537225 = r537222 - r537224;
        double r537226 = fma(r537220, r537225, r537223);
        double r537227 = r537220 - r537213;
        double r537228 = 1.0;
        double r537229 = a;
        double r537230 = r537229 - r537213;
        double r537231 = r537228 / r537230;
        double r537232 = r537227 * r537231;
        double r537233 = r537223 - r537221;
        double r537234 = r537232 * r537233;
        double r537235 = r537234 + r537221;
        double r537236 = r537219 ? r537226 : r537235;
        return r537236;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target12.0
Herbie10.1
\[\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 < -3.4061378560533744e+174 or 4.166554550604968e+139 < z

    1. Initial program 47.5

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

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

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

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

    if -3.4061378560533744e+174 < z < 4.166554550604968e+139

    1. Initial program 15.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.40613785605337445 \cdot 10^{174} \lor \neg \left(z \le 4.166554550604968 \cdot 10^{139}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(y - z\right) \cdot \frac{1}{a - z}\right) \cdot \left(t - x\right) + x\\ \end{array}\]

Reproduce

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