Average Error: 24.1 → 10.4
Time: 6.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.44153430836384812 \cdot 10^{49} \lor \neg \left(z \le 1.782566557548187 \cdot 10^{198}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t - x\right) \cdot \frac{y - z}{a - z} + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -1.44153430836384812 \cdot 10^{49} \lor \neg \left(z \le 1.782566557548187 \cdot 10^{198}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r628397 = x;
        double r628398 = y;
        double r628399 = z;
        double r628400 = r628398 - r628399;
        double r628401 = t;
        double r628402 = r628401 - r628397;
        double r628403 = r628400 * r628402;
        double r628404 = a;
        double r628405 = r628404 - r628399;
        double r628406 = r628403 / r628405;
        double r628407 = r628397 + r628406;
        return r628407;
}

double f(double x, double y, double z, double t, double a) {
        double r628408 = z;
        double r628409 = -1.441534308363848e+49;
        bool r628410 = r628408 <= r628409;
        double r628411 = 1.782566557548187e+198;
        bool r628412 = r628408 <= r628411;
        double r628413 = !r628412;
        bool r628414 = r628410 || r628413;
        double r628415 = y;
        double r628416 = x;
        double r628417 = r628416 / r628408;
        double r628418 = t;
        double r628419 = r628418 / r628408;
        double r628420 = r628417 - r628419;
        double r628421 = fma(r628415, r628420, r628418);
        double r628422 = r628418 - r628416;
        double r628423 = r628415 - r628408;
        double r628424 = a;
        double r628425 = r628424 - r628408;
        double r628426 = r628423 / r628425;
        double r628427 = r628422 * r628426;
        double r628428 = r628427 + r628416;
        double r628429 = r628414 ? r628421 : r628428;
        return r628429;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.1
Target11.7
Herbie10.4
\[\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.441534308363848e+49 or 1.782566557548187e+198 < z

    1. Initial program 43.8

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

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

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

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

    if -1.441534308363848e+49 < z < 1.782566557548187e+198

    1. Initial program 14.2

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

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

      \[\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-udef6.7

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

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

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

Reproduce

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