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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r563302 = x;
        double r563303 = y;
        double r563304 = z;
        double r563305 = r563303 - r563304;
        double r563306 = t;
        double r563307 = r563306 - r563302;
        double r563308 = r563305 * r563307;
        double r563309 = a;
        double r563310 = r563309 - r563304;
        double r563311 = r563308 / r563310;
        double r563312 = r563302 + r563311;
        return r563312;
}

double f(double x, double y, double z, double t, double a) {
        double r563313 = x;
        double r563314 = y;
        double r563315 = z;
        double r563316 = r563314 - r563315;
        double r563317 = t;
        double r563318 = r563317 - r563313;
        double r563319 = r563316 * r563318;
        double r563320 = a;
        double r563321 = r563320 - r563315;
        double r563322 = r563319 / r563321;
        double r563323 = r563313 + r563322;
        double r563324 = -1.1885489098433182e-292;
        bool r563325 = r563323 <= r563324;
        double r563326 = 0.0;
        bool r563327 = r563323 <= r563326;
        double r563328 = !r563327;
        bool r563329 = r563325 || r563328;
        double r563330 = r563314 / r563321;
        double r563331 = r563315 / r563321;
        double r563332 = r563330 - r563331;
        double r563333 = r563317 * r563332;
        double r563334 = -r563313;
        double r563335 = r563316 / r563321;
        double r563336 = fma(r563334, r563335, r563313);
        double r563337 = r563333 + r563336;
        double r563338 = 1.0;
        double r563339 = r563321 / r563316;
        double r563340 = r563338 / r563339;
        double r563341 = r563317 * r563340;
        double r563342 = r563313 * r563314;
        double r563343 = r563342 / r563315;
        double r563344 = r563341 + r563343;
        double r563345 = r563329 ? r563337 : r563344;
        return r563345;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.6
Target11.8
Herbie6.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 (+ x (/ (* (- y z) (- t x)) (- a z))) < -1.1885489098433182e-292 or 0.0 < (+ x (/ (* (- y z) (- t x)) (- a z)))

    1. Initial program 21.4

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

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    7. Applied distribute-rgt-in7.3

      \[\leadsto \color{blue}{\left(t \cdot \frac{y - z}{a - z} + \left(-x\right) \cdot \frac{y - z}{a - z}\right)} + x\]
    8. Applied associate-+l+4.9

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

      \[\leadsto t \cdot \frac{y - z}{a - z} + \color{blue}{\mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)}\]
    10. Using strategy rm
    11. Applied div-sub4.9

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

    if -1.1885489098433182e-292 < (+ x (/ (* (- y z) (- t x)) (- a z))) < 0.0

    1. Initial program 60.4

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

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

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

      \[\leadsto \frac{y - z}{a - z} \cdot \color{blue}{\left(t + \left(-x\right)\right)} + x\]
    7. Applied distribute-rgt-in60.3

      \[\leadsto \color{blue}{\left(t \cdot \frac{y - z}{a - z} + \left(-x\right) \cdot \frac{y - z}{a - z}\right)} + x\]
    8. Applied associate-+l+34.6

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

      \[\leadsto t \cdot \frac{y - z}{a - z} + \color{blue}{\mathsf{fma}\left(-x, \frac{y - z}{a - z}, x\right)}\]
    10. Using strategy rm
    11. Applied clear-num34.6

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

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

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

Reproduce

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