Average Error: 23.3 → 10.7
Time: 20.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -8.589035675987075 \cdot 10^{-82}:\\ \;\;\;\;\mathsf{fma}\left(\frac{1}{a - z} \cdot \left(t - x\right), y - z, x\right)\\ \mathbf{elif}\;a \le 4.018665187593768 \cdot 10^{-186}:\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{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}\;a \le -8.589035675987075 \cdot 10^{-82}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{a - z} \cdot \left(t - x\right), y - z, x\right)\\

\mathbf{elif}\;a \le 4.018665187593768 \cdot 10^{-186}:\\
\;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r30442704 = x;
        double r30442705 = y;
        double r30442706 = z;
        double r30442707 = r30442705 - r30442706;
        double r30442708 = t;
        double r30442709 = r30442708 - r30442704;
        double r30442710 = r30442707 * r30442709;
        double r30442711 = a;
        double r30442712 = r30442711 - r30442706;
        double r30442713 = r30442710 / r30442712;
        double r30442714 = r30442704 + r30442713;
        return r30442714;
}

double f(double x, double y, double z, double t, double a) {
        double r30442715 = a;
        double r30442716 = -8.589035675987075e-82;
        bool r30442717 = r30442715 <= r30442716;
        double r30442718 = 1.0;
        double r30442719 = z;
        double r30442720 = r30442715 - r30442719;
        double r30442721 = r30442718 / r30442720;
        double r30442722 = t;
        double r30442723 = x;
        double r30442724 = r30442722 - r30442723;
        double r30442725 = r30442721 * r30442724;
        double r30442726 = y;
        double r30442727 = r30442726 - r30442719;
        double r30442728 = fma(r30442725, r30442727, r30442723);
        double r30442729 = 4.018665187593768e-186;
        bool r30442730 = r30442715 <= r30442729;
        double r30442731 = r30442723 / r30442719;
        double r30442732 = r30442722 / r30442719;
        double r30442733 = r30442731 - r30442732;
        double r30442734 = r30442726 * r30442733;
        double r30442735 = r30442722 + r30442734;
        double r30442736 = r30442720 / r30442727;
        double r30442737 = r30442718 / r30442736;
        double r30442738 = r30442737 * r30442724;
        double r30442739 = r30442723 + r30442738;
        double r30442740 = r30442730 ? r30442735 : r30442739;
        double r30442741 = r30442717 ? r30442728 : r30442740;
        return r30442741;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.3
Target11.8
Herbie10.7
\[\begin{array}{l} \mathbf{if}\;z \lt -1.2536131056095036 \cdot 10^{+188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z \lt 4.446702369113811 \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 a < -8.589035675987075e-82

    1. Initial program 20.7

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

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

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

    if -8.589035675987075e-82 < a < 4.018665187593768e-186

    1. Initial program 28.2

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

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

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

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

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

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

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

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

    if 4.018665187593768e-186 < a

    1. Initial program 22.5

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

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

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

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

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

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

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

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

Reproduce

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