Average Error: 24.5 → 10.1
Time: 12.7s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -3.10252611137827803 \cdot 10^{112} \lor \neg \left(z \le 1.30984479346046122 \cdot 10^{176}\right):\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \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}\;z \le -3.10252611137827803 \cdot 10^{112} \lor \neg \left(z \le 1.30984479346046122 \cdot 10^{176}\right):\\
\;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\

\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 r674069 = x;
        double r674070 = y;
        double r674071 = z;
        double r674072 = r674070 - r674071;
        double r674073 = t;
        double r674074 = r674073 - r674069;
        double r674075 = r674072 * r674074;
        double r674076 = a;
        double r674077 = r674076 - r674071;
        double r674078 = r674075 / r674077;
        double r674079 = r674069 + r674078;
        return r674079;
}

double f(double x, double y, double z, double t, double a) {
        double r674080 = z;
        double r674081 = -3.102526111378278e+112;
        bool r674082 = r674080 <= r674081;
        double r674083 = 1.3098447934604612e+176;
        bool r674084 = r674080 <= r674083;
        double r674085 = !r674084;
        bool r674086 = r674082 || r674085;
        double r674087 = t;
        double r674088 = y;
        double r674089 = x;
        double r674090 = r674089 / r674080;
        double r674091 = r674087 / r674080;
        double r674092 = r674090 - r674091;
        double r674093 = r674088 * r674092;
        double r674094 = r674087 + r674093;
        double r674095 = r674088 - r674080;
        double r674096 = a;
        double r674097 = r674096 - r674080;
        double r674098 = r674095 / r674097;
        double r674099 = r674087 - r674089;
        double r674100 = fma(r674098, r674099, r674089);
        double r674101 = r674086 ? r674094 : r674100;
        return r674101;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.5
Target11.7
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.102526111378278e+112 or 1.3098447934604612e+176 < z

    1. Initial program 46.6

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

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

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

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

    if -3.102526111378278e+112 < z < 1.3098447934604612e+176

    1. Initial program 15.2

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

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

      \[\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 un-div-inv7.2

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

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

Reproduce

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