Average Error: 24.5 → 10.0
Time: 11.8s
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}:\\ \;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\ \mathbf{elif}\;z \le 1.15082174081778273 \cdot 10^{176}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - 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}:\\
\;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r693281 = x;
        double r693282 = y;
        double r693283 = z;
        double r693284 = r693282 - r693283;
        double r693285 = t;
        double r693286 = r693285 - r693281;
        double r693287 = r693284 * r693286;
        double r693288 = a;
        double r693289 = r693288 - r693283;
        double r693290 = r693287 / r693289;
        double r693291 = r693281 + r693290;
        return r693291;
}

double f(double x, double y, double z, double t, double a) {
        double r693292 = z;
        double r693293 = -3.102526111378278e+112;
        bool r693294 = r693292 <= r693293;
        double r693295 = y;
        double r693296 = x;
        double r693297 = r693296 / r693292;
        double r693298 = t;
        double r693299 = r693298 / r693292;
        double r693300 = r693297 - r693299;
        double r693301 = r693295 * r693300;
        double r693302 = r693301 + r693298;
        double r693303 = 1.1508217408177827e+176;
        bool r693304 = r693292 <= r693303;
        double r693305 = r693295 - r693292;
        double r693306 = a;
        double r693307 = r693306 - r693292;
        double r693308 = r693305 / r693307;
        double r693309 = r693298 - r693296;
        double r693310 = fma(r693308, r693309, r693296);
        double r693311 = r693295 / r693292;
        double r693312 = r693311 * r693309;
        double r693313 = r693298 - r693312;
        double r693314 = r693304 ? r693310 : r693313;
        double r693315 = r693294 ? r693302 : r693314;
        return r693315;
}

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.0
\[\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 3 regimes
  2. if z < -3.102526111378278e+112

    1. Initial program 44.4

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

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

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

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

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

    if -3.102526111378278e+112 < z < 1.1508217408177827e+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 pow17.3

      \[\leadsto \mathsf{fma}\left(\left(y - z\right) \cdot \color{blue}{{\left(\frac{1}{a - z}\right)}^{1}}, t - x, x\right)\]
    7. Applied pow17.3

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(y - z\right)}^{1}} \cdot {\left(\frac{1}{a - z}\right)}^{1}, t - x, x\right)\]
    8. Applied pow-prod-down7.3

      \[\leadsto \mathsf{fma}\left(\color{blue}{{\left(\left(y - z\right) \cdot \frac{1}{a - z}\right)}^{1}}, t - x, x\right)\]
    9. Simplified7.2

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

    if 1.1508217408177827e+176 < z

    1. Initial program 49.9

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -3.10252611137827803 \cdot 10^{112}:\\ \;\;\;\;y \cdot \left(\frac{x}{z} - \frac{t}{z}\right) + t\\ \mathbf{elif}\;z \le 1.15082174081778273 \cdot 10^{176}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - 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))))