Average Error: 23.8 → 14.8
Time: 21.3s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;y \le 1.285655334612926 \cdot 10^{-253}:\\ \;\;\;\;\mathsf{fma}\left(\left(t - x\right) \cdot \frac{1}{a - z}, y - z, x\right)\\ \mathbf{elif}\;y \le 1.6219312397286576 \cdot 10^{-168}:\\ \;\;\;\;\frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} + x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\left(t - x\right) \cdot \frac{1}{a - z}, y - z, x\right)\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;y \le 1.285655334612926 \cdot 10^{-253}:\\
\;\;\;\;\mathsf{fma}\left(\left(t - x\right) \cdot \frac{1}{a - z}, y - z, x\right)\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r28325966 = x;
        double r28325967 = y;
        double r28325968 = z;
        double r28325969 = r28325967 - r28325968;
        double r28325970 = t;
        double r28325971 = r28325970 - r28325966;
        double r28325972 = r28325969 * r28325971;
        double r28325973 = a;
        double r28325974 = r28325973 - r28325968;
        double r28325975 = r28325972 / r28325974;
        double r28325976 = r28325966 + r28325975;
        return r28325976;
}

double f(double x, double y, double z, double t, double a) {
        double r28325977 = y;
        double r28325978 = 1.285655334612926e-253;
        bool r28325979 = r28325977 <= r28325978;
        double r28325980 = t;
        double r28325981 = x;
        double r28325982 = r28325980 - r28325981;
        double r28325983 = 1.0;
        double r28325984 = a;
        double r28325985 = z;
        double r28325986 = r28325984 - r28325985;
        double r28325987 = r28325983 / r28325986;
        double r28325988 = r28325982 * r28325987;
        double r28325989 = r28325977 - r28325985;
        double r28325990 = fma(r28325988, r28325989, r28325981);
        double r28325991 = 1.6219312397286576e-168;
        bool r28325992 = r28325977 <= r28325991;
        double r28325993 = r28325989 * r28325982;
        double r28325994 = r28325993 / r28325986;
        double r28325995 = r28325994 + r28325981;
        double r28325996 = r28325992 ? r28325995 : r28325990;
        double r28325997 = r28325979 ? r28325990 : r28325996;
        return r28325997;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original23.8
Target11.7
Herbie14.8
\[\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 2 regimes
  2. if y < 1.285655334612926e-253 or 1.6219312397286576e-168 < y

    1. Initial program 24.1

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

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

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

    if 1.285655334612926e-253 < y < 1.6219312397286576e-168

    1. Initial program 21.1

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

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

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

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

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

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

Reproduce

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