Average Error: 24.1 → 10.5
Time: 24.4s
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 r21812462 = x;
        double r21812463 = y;
        double r21812464 = z;
        double r21812465 = r21812463 - r21812464;
        double r21812466 = t;
        double r21812467 = r21812466 - r21812462;
        double r21812468 = r21812465 * r21812467;
        double r21812469 = a;
        double r21812470 = r21812469 - r21812464;
        double r21812471 = r21812468 / r21812470;
        double r21812472 = r21812462 + r21812471;
        return r21812472;
}

double f(double x, double y, double z, double t, double a) {
        double r21812473 = z;
        double r21812474 = 2.692918381213643e+179;
        bool r21812475 = r21812473 <= r21812474;
        double r21812476 = x;
        double r21812477 = t;
        double r21812478 = r21812477 - r21812476;
        double r21812479 = y;
        double r21812480 = r21812479 - r21812473;
        double r21812481 = a;
        double r21812482 = r21812481 - r21812473;
        double r21812483 = r21812480 / r21812482;
        double r21812484 = r21812478 * r21812483;
        double r21812485 = r21812476 + r21812484;
        double r21812486 = r21812476 / r21812473;
        double r21812487 = r21812477 / r21812473;
        double r21812488 = r21812486 - r21812487;
        double r21812489 = fma(r21812479, r21812488, r21812477);
        double r21812490 = r21812475 ? r21812485 : r21812489;
        return r21812490;
}

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