Average Error: 24.5 → 9.7
Time: 14.7s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.1914594564867916 \cdot 10^{238} \lor \neg \left(z \le 1.1134789946894111 \cdot 10^{226}\right):\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t - x}{\frac{a - z}{y - z}} + x\\ \end{array}\]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \le -9.1914594564867916 \cdot 10^{238} \lor \neg \left(z \le 1.1134789946894111 \cdot 10^{226}\right):\\
\;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r651029 = x;
        double r651030 = y;
        double r651031 = z;
        double r651032 = r651030 - r651031;
        double r651033 = t;
        double r651034 = r651033 - r651029;
        double r651035 = r651032 * r651034;
        double r651036 = a;
        double r651037 = r651036 - r651031;
        double r651038 = r651035 / r651037;
        double r651039 = r651029 + r651038;
        return r651039;
}

double f(double x, double y, double z, double t, double a) {
        double r651040 = z;
        double r651041 = -9.191459456486792e+238;
        bool r651042 = r651040 <= r651041;
        double r651043 = 1.1134789946894111e+226;
        bool r651044 = r651040 <= r651043;
        double r651045 = !r651044;
        bool r651046 = r651042 || r651045;
        double r651047 = t;
        double r651048 = y;
        double r651049 = x;
        double r651050 = r651049 / r651040;
        double r651051 = r651047 / r651040;
        double r651052 = r651050 - r651051;
        double r651053 = r651048 * r651052;
        double r651054 = r651047 + r651053;
        double r651055 = r651047 - r651049;
        double r651056 = a;
        double r651057 = r651056 - r651040;
        double r651058 = r651048 - r651040;
        double r651059 = r651057 / r651058;
        double r651060 = r651055 / r651059;
        double r651061 = r651060 + r651049;
        double r651062 = r651046 ? r651054 : r651061;
        return r651062;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original24.5
Target12.0
Herbie9.7
\[\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 z < -9.191459456486792e+238 or 1.1134789946894111e+226 < z

    1. Initial program 52.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, t - x, x\right)}\]
    3. Taylor expanded around inf 23.2

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

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

    if -9.191459456486792e+238 < z < 1.1134789946894111e+226

    1. Initial program 19.9

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

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

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

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

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

      \[\leadsto \left(t - x\right) \cdot \color{blue}{\frac{1}{\frac{a - z}{y - z}}} + x\]
    10. Using strategy rm
    11. Applied un-div-inv9.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -9.1914594564867916 \cdot 10^{238} \lor \neg \left(z \le 1.1134789946894111 \cdot 10^{226}\right):\\ \;\;\;\;t + y \cdot \left(\frac{x}{z} - \frac{t}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{t - x}{\frac{a - z}{y - z}} + x\\ \end{array}\]

Reproduce

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