Average Error: 24.1 → 10.5
Time: 25.2s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le 2.692918381213642726516273228742192808541 \cdot 10^{179}:\\ \;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{x}{z} - \frac{t}{z}, t\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le 2.692918381213642726516273228742192808541 \cdot 10^{179}:\\
\;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r25419341 = x;
        double r25419342 = y;
        double r25419343 = z;
        double r25419344 = r25419342 - r25419343;
        double r25419345 = t;
        double r25419346 = r25419345 - r25419341;
        double r25419347 = r25419344 * r25419346;
        double r25419348 = a;
        double r25419349 = r25419348 - r25419343;
        double r25419350 = r25419347 / r25419349;
        double r25419351 = r25419341 + r25419350;
        return r25419351;
}

double f(double x, double y, double z, double t, double a) {
        double r25419352 = z;
        double r25419353 = 2.692918381213643e+179;
        bool r25419354 = r25419352 <= r25419353;
        double r25419355 = x;
        double r25419356 = t;
        double r25419357 = r25419356 - r25419355;
        double r25419358 = y;
        double r25419359 = r25419358 - r25419352;
        double r25419360 = a;
        double r25419361 = r25419360 - r25419352;
        double r25419362 = r25419359 / r25419361;
        double r25419363 = r25419357 * r25419362;
        double r25419364 = r25419355 + r25419363;
        double r25419365 = r25419355 / r25419352;
        double r25419366 = r25419356 / r25419352;
        double r25419367 = r25419365 - r25419366;
        double r25419368 = fma(r25419358, r25419367, r25419356);
        double r25419369 = r25419354 ? r25419364 : r25419368;
        return r25419369;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.1
Target12.1
Herbie10.5
\[\begin{array}{l} \mathbf{if}\;z \lt -1.253613105609503593846459977496550767343 \cdot 10^{188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811028051510715777703865332 \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 < 2.692918381213643e+179

    1. Initial program 20.8

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

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

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

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

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

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

    if 2.692918381213643e+179 < z

    1. Initial program 47.8

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

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

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

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

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

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

      \[\leadsto \left(t - x\right) \cdot \color{blue}{\left(\left(\sqrt[3]{\frac{y - z}{a - z}} \cdot \sqrt[3]{\frac{y - z}{a - z}}\right) \cdot \sqrt[3]{\frac{y - z}{a - z}}\right)} + x\]
    11. Applied associate-*r*23.1

      \[\leadsto \color{blue}{\left(\left(t - x\right) \cdot \left(\sqrt[3]{\frac{y - z}{a - z}} \cdot \sqrt[3]{\frac{y - z}{a - z}}\right)\right) \cdot \sqrt[3]{\frac{y - z}{a - z}}} + x\]
    12. Taylor expanded around inf 24.4

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

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

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

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"

  :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))))