Average Error: 25.1 → 9.6
Time: 27.4s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.05779727369286190042854981278171337128 \cdot 10^{192} \lor \neg \left(z \le 4.892583137041056825995118094598819433784 \cdot 10^{158}\right):\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\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 -1.05779727369286190042854981278171337128 \cdot 10^{192} \lor \neg \left(z \le 4.892583137041056825995118094598819433784 \cdot 10^{158}\right):\\
\;\;\;\;t - \frac{y}{z} \cdot \left(t - x\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 r412941 = x;
        double r412942 = y;
        double r412943 = z;
        double r412944 = r412942 - r412943;
        double r412945 = t;
        double r412946 = r412945 - r412941;
        double r412947 = r412944 * r412946;
        double r412948 = a;
        double r412949 = r412948 - r412943;
        double r412950 = r412947 / r412949;
        double r412951 = r412941 + r412950;
        return r412951;
}

double f(double x, double y, double z, double t, double a) {
        double r412952 = z;
        double r412953 = -1.0577972736928619e+192;
        bool r412954 = r412952 <= r412953;
        double r412955 = 4.892583137041057e+158;
        bool r412956 = r412952 <= r412955;
        double r412957 = !r412956;
        bool r412958 = r412954 || r412957;
        double r412959 = t;
        double r412960 = y;
        double r412961 = r412960 / r412952;
        double r412962 = x;
        double r412963 = r412959 - r412962;
        double r412964 = r412961 * r412963;
        double r412965 = r412959 - r412964;
        double r412966 = a;
        double r412967 = r412966 - r412952;
        double r412968 = r412960 - r412952;
        double r412969 = r412967 / r412968;
        double r412970 = r412963 / r412969;
        double r412971 = r412970 + r412962;
        double r412972 = r412958 ? r412965 : r412971;
        return r412972;
}

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

Original25.1
Target11.8
Herbie9.6
\[\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 < -1.0577972736928619e+192 or 4.892583137041057e+158 < z

    1. Initial program 49.6

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

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

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

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

    if -1.0577972736928619e+192 < z < 4.892583137041057e+158

    1. Initial program 17.0

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

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

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

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

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

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

Reproduce

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