Average Error: 24.5 → 9.7
Time: 5.5s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.1914594564867916 \cdot 10^{238} \lor \neg \left(z \le 1.1134789946894111 \cdot 10^{226}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(\frac{t - x}{\frac{a - z}{y - z}}\right)}^{1} + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -9.1914594564867916 \cdot 10^{238} \lor \neg \left(z \le 1.1134789946894111 \cdot 10^{226}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r586167 = x;
        double r586168 = y;
        double r586169 = z;
        double r586170 = r586168 - r586169;
        double r586171 = t;
        double r586172 = r586171 - r586167;
        double r586173 = r586170 * r586172;
        double r586174 = a;
        double r586175 = r586174 - r586169;
        double r586176 = r586173 / r586175;
        double r586177 = r586167 + r586176;
        return r586177;
}

double f(double x, double y, double z, double t, double a) {
        double r586178 = z;
        double r586179 = -9.191459456486792e+238;
        bool r586180 = r586178 <= r586179;
        double r586181 = 1.1134789946894111e+226;
        bool r586182 = r586178 <= r586181;
        double r586183 = !r586182;
        bool r586184 = r586180 || r586183;
        double r586185 = y;
        double r586186 = x;
        double r586187 = r586186 / r586178;
        double r586188 = t;
        double r586189 = r586188 / r586178;
        double r586190 = r586187 - r586189;
        double r586191 = fma(r586185, r586190, r586188);
        double r586192 = r586188 - r586186;
        double r586193 = a;
        double r586194 = r586193 - r586178;
        double r586195 = r586185 - r586178;
        double r586196 = r586194 / r586195;
        double r586197 = r586192 / r586196;
        double r586198 = 1.0;
        double r586199 = pow(r586197, r586198);
        double r586200 = r586199 + r586186;
        double r586201 = r586184 ? r586191 : r586200;
        return r586201;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.5
Target12.0
Herbie9.7
\[\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 < -9.191459456486792e+238 or 1.1134789946894111e+226 < z

    1. Initial program 52.3

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

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

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

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

    if -9.191459456486792e+238 < z < 1.1134789946894111e+226

    1. Initial program 19.9

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

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

      \[\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-udef9.2

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

      \[\leadsto \color{blue}{\left(t - x\right) \cdot \frac{y - z}{a - z}} + x\]
    8. Using strategy rm
    9. Applied clear-num9.2

      \[\leadsto \left(t - x\right) \cdot \color{blue}{\frac{1}{\frac{a - z}{y - z}}} + x\]
    10. Using strategy rm
    11. Applied pow19.2

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

      \[\leadsto \color{blue}{{\left(t - x\right)}^{1}} \cdot {\left(\frac{1}{\frac{a - z}{y - z}}\right)}^{1} + x\]
    13. Applied pow-prod-down9.2

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

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

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

Reproduce

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