Average Error: 24.5 → 8.4
Time: 16.8s
Precision: binary64
\[x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;t_1 \leq -1.297074943997487 \cdot 10^{-230}:\\ \;\;\;\;\left(\frac{x \cdot t}{a - t} + \left(x + \frac{y \cdot z}{a - t}\right)\right) - \left(\frac{x \cdot z}{a - t} + \frac{y \cdot t}{a - t}\right)\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;\left(y + \left(\frac{x \cdot z}{t} + \frac{y \cdot a}{t}\right)\right) - \left(\frac{x \cdot a}{t} + \frac{y \cdot z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a - t} - \frac{t}{a - t}, x\right)\\ \end{array} \]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;y \cdot \frac{z - t}{a - t}\\

\mathbf{elif}\;t_1 \leq -1.297074943997487 \cdot 10^{-230}:\\
\;\;\;\;\left(\frac{x \cdot t}{a - t} + \left(x + \frac{y \cdot z}{a - t}\right)\right) - \left(\frac{x \cdot z}{a - t} + \frac{y \cdot t}{a - t}\right)\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\left(y + \left(\frac{x \cdot z}{t} + \frac{y \cdot a}{t}\right)\right) - \left(\frac{x \cdot a}{t} + \frac{y \cdot z}{t}\right)\\

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


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
   (if (<= t_1 (- INFINITY))
     (* y (/ (- z t) (- a t)))
     (if (<= t_1 -1.297074943997487e-230)
       (-
        (+ (/ (* x t) (- a t)) (+ x (/ (* y z) (- a t))))
        (+ (/ (* x z) (- a t)) (/ (* y t) (- a t))))
       (if (<= t_1 0.0)
         (-
          (+ y (+ (/ (* x z) t) (/ (* y a) t)))
          (+ (/ (* x a) t) (/ (* y z) t)))
         (fma (- y x) (- (/ z (- a t)) (/ t (- a t))) x))))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - x) * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = x + (((y - x) * (z - t)) / (a - t));
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = y * ((z - t) / (a - t));
	} else if (t_1 <= -1.297074943997487e-230) {
		tmp = (((x * t) / (a - t)) + (x + ((y * z) / (a - t)))) - (((x * z) / (a - t)) + ((y * t) / (a - t)));
	} else if (t_1 <= 0.0) {
		tmp = (y + (((x * z) / t) + ((y * a) / t))) - (((x * a) / t) + ((y * z) / t));
	} else {
		tmp = fma((y - x), ((z / (a - t)) - (t / (a - t))), x);
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original24.5
Target9.5
Herbie8.4
\[\begin{array}{l} \mathbf{if}\;a < -1.6153062845442575 \cdot 10^{-142}:\\ \;\;\;\;x + \frac{y - x}{1} \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;a < 3.774403170083174 \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 4 regimes
  2. if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -inf.0

    1. Initial program 64.0

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

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

      \[\leadsto \color{blue}{\left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y} \]
    4. Simplified25.5

      \[\leadsto \color{blue}{y \cdot \frac{z - t}{a - t}} \]

    if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -1.297074943997487e-230

    1. Initial program 2.2

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

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

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

    if -1.297074943997487e-230 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0

    1. Initial program 54.3

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

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

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

    if 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t)))

    1. Initial program 21.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)} \]
    3. Applied *-un-lft-identity_binary648.0

      \[\leadsto \mathsf{fma}\left(y - x, \frac{z - t}{\color{blue}{1 \cdot \left(a - t\right)}}, x\right) \]
    4. Applied add-cube-cbrt_binary648.7

      \[\leadsto \mathsf{fma}\left(y - x, \frac{\color{blue}{\left(\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}\right) \cdot \sqrt[3]{z - t}}}{1 \cdot \left(a - t\right)}, x\right) \]
    5. Applied times-frac_binary648.7

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

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\left(\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}\right)} \cdot \frac{\sqrt[3]{z - t}}{a - t}, x\right) \]
    7. Taylor expanded in z around 0 8.0

      \[\leadsto \mathsf{fma}\left(y - x, \color{blue}{\frac{z}{a - t} - \frac{t}{a - t}}, x\right) \]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \leq -\infty:\\ \;\;\;\;y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \leq -1.297074943997487 \cdot 10^{-230}:\\ \;\;\;\;\left(\frac{x \cdot t}{a - t} + \left(x + \frac{y \cdot z}{a - t}\right)\right) - \left(\frac{x \cdot z}{a - t} + \frac{y \cdot t}{a - t}\right)\\ \mathbf{elif}\;x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} \leq 0:\\ \;\;\;\;\left(y + \left(\frac{x \cdot z}{t} + \frac{y \cdot a}{t}\right)\right) - \left(\frac{x \cdot a}{t} + \frac{y \cdot z}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a - t} - \frac{t}{a - t}, x\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2021313 
(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.0) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))

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