Average Error: 24.6 → 11.6
Time: 12.1s
Precision: 64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;a \le -4.0098790375020589 \cdot 10^{-70}:\\ \;\;\;\;\frac{y - x}{a - t} \cdot \left(z - t\right) + x\\ \mathbf{elif}\;a \le 3.8034022935305039 \cdot 10^{-125}:\\ \;\;\;\;\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \end{array}\]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;a \le -4.0098790375020589 \cdot 10^{-70}:\\
\;\;\;\;\frac{y - x}{a - t} \cdot \left(z - t\right) + x\\

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

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r738076 = x;
        double r738077 = y;
        double r738078 = r738077 - r738076;
        double r738079 = z;
        double r738080 = t;
        double r738081 = r738079 - r738080;
        double r738082 = r738078 * r738081;
        double r738083 = a;
        double r738084 = r738083 - r738080;
        double r738085 = r738082 / r738084;
        double r738086 = r738076 + r738085;
        return r738086;
}

double f(double x, double y, double z, double t, double a) {
        double r738087 = a;
        double r738088 = -4.009879037502059e-70;
        bool r738089 = r738087 <= r738088;
        double r738090 = y;
        double r738091 = x;
        double r738092 = r738090 - r738091;
        double r738093 = t;
        double r738094 = r738087 - r738093;
        double r738095 = r738092 / r738094;
        double r738096 = z;
        double r738097 = r738096 - r738093;
        double r738098 = r738095 * r738097;
        double r738099 = r738098 + r738091;
        double r738100 = 3.803402293530504e-125;
        bool r738101 = r738087 <= r738100;
        double r738102 = r738091 * r738096;
        double r738103 = r738102 / r738093;
        double r738104 = r738090 + r738103;
        double r738105 = r738096 * r738090;
        double r738106 = r738105 / r738093;
        double r738107 = r738104 - r738106;
        double r738108 = r738097 / r738094;
        double r738109 = r738092 * r738108;
        double r738110 = r738109 + r738091;
        double r738111 = r738101 ? r738107 : r738110;
        double r738112 = r738089 ? r738099 : r738111;
        return r738112;
}

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.6
Target9.1
Herbie11.6
\[\begin{array}{l} \mathbf{if}\;a \lt -1.6153062845442575 \cdot 10^{-142}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;a \lt 3.7744031700831742 \cdot 10^{-182}:\\ \;\;\;\;y - \frac{z}{t} \cdot \left(y - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if a < -4.009879037502059e-70

    1. Initial program 23.0

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

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

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

    if -4.009879037502059e-70 < a < 3.803402293530504e-125

    1. Initial program 29.2

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

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

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

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

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

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

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

    if 3.803402293530504e-125 < a

    1. Initial program 22.2

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \le -4.0098790375020589 \cdot 10^{-70}:\\ \;\;\;\;\frac{y - x}{a - t} \cdot \left(z - t\right) + x\\ \mathbf{elif}\;a \le 3.8034022935305039 \cdot 10^{-125}:\\ \;\;\;\;\left(y + \frac{x \cdot z}{t}\right) - \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \frac{z - t}{a - t} + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1) (/ (- z t) (- a t))))))

  (+ x (/ (* (- y x) (- z t)) (- a t))))