Average Error: 24.1 → 9.3
Time: 19.1s
Precision: 64
\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\]
\[\begin{array}{l} \mathbf{if}\;a \le -3.05828487626015833265941954080526345918 \cdot 10^{-127}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\ \mathbf{elif}\;a \le 6.713273107564123459794063379500506096135 \cdot 10^{-136}:\\ \;\;\;\;\left(\frac{x}{z} - \frac{t}{z}\right) \cdot y + t\\ \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 -3.05828487626015833265941954080526345918 \cdot 10^{-127}:\\
\;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\

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

\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 r31028970 = x;
        double r31028971 = y;
        double r31028972 = z;
        double r31028973 = r31028971 - r31028972;
        double r31028974 = t;
        double r31028975 = r31028974 - r31028970;
        double r31028976 = r31028973 * r31028975;
        double r31028977 = a;
        double r31028978 = r31028977 - r31028972;
        double r31028979 = r31028976 / r31028978;
        double r31028980 = r31028970 + r31028979;
        return r31028980;
}

double f(double x, double y, double z, double t, double a) {
        double r31028981 = a;
        double r31028982 = -3.0582848762601583e-127;
        bool r31028983 = r31028981 <= r31028982;
        double r31028984 = x;
        double r31028985 = 1.0;
        double r31028986 = z;
        double r31028987 = r31028981 - r31028986;
        double r31028988 = y;
        double r31028989 = r31028988 - r31028986;
        double r31028990 = r31028987 / r31028989;
        double r31028991 = r31028985 / r31028990;
        double r31028992 = t;
        double r31028993 = r31028992 - r31028984;
        double r31028994 = r31028991 * r31028993;
        double r31028995 = r31028984 + r31028994;
        double r31028996 = 6.7132731075641235e-136;
        bool r31028997 = r31028981 <= r31028996;
        double r31028998 = r31028984 / r31028986;
        double r31028999 = r31028992 / r31028986;
        double r31029000 = r31028998 - r31028999;
        double r31029001 = r31029000 * r31028988;
        double r31029002 = r31029001 + r31028992;
        double r31029003 = r31028997 ? r31029002 : r31028995;
        double r31029004 = r31028983 ? r31028995 : r31029003;
        return r31029004;
}

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.1
Target11.9
Herbie9.3
\[\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 a < -3.0582848762601583e-127 or 6.7132731075641235e-136 < a

    1. Initial program 22.1

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

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

      \[\leadsto \color{blue}{\frac{t - x}{a - z} \cdot \left(y - z\right) + x}\]
    5. Using strategy rm
    6. Applied div-inv11.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*8.6

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

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

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

    if -3.0582848762601583e-127 < a < 6.7132731075641235e-136

    1. Initial program 30.0

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -3.05828487626015833265941954080526345918 \cdot 10^{-127}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\ \mathbf{elif}\;a \le 6.713273107564123459794063379500506096135 \cdot 10^{-136}:\\ \;\;\;\;\left(\frac{x}{z} - \frac{t}{z}\right) \cdot y + t\\ \mathbf{else}:\\ \;\;\;\;x + \frac{1}{\frac{a - z}{y - z}} \cdot \left(t - x\right)\\ \end{array}\]

Reproduce

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