Average Error: 12.0 → 5.5
Time: 26.9s
Precision: binary64
\[x + \left(y - z\right) \cdot \frac{t - x}{a - z} \]
\[\begin{array}{l} t_1 := \frac{t - x}{a - z}\\ t_2 := x + \left(y - z\right) \cdot t_1\\ t_3 := \mathsf{fma}\left(y - z, t_1, x\right)\\ \mathbf{if}\;t_2 \leq -2.271715210522009 \cdot 10^{-255}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;\left(\frac{x \cdot y}{z} + \left(t + \frac{t \cdot a}{z}\right)\right) - \left(\frac{y \cdot t}{z} + \frac{x \cdot a}{z}\right)\\ \mathbf{elif}\;t_2 \leq 6.722453214872935 \cdot 10^{-48}:\\ \;\;\;\;\left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{x \cdot y}{a - z} + \frac{z \cdot t}{a - z}\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\begin{array}{l}
t_1 := \frac{t - x}{a - z}\\
t_2 := x + \left(y - z\right) \cdot t_1\\
t_3 := \mathsf{fma}\left(y - z, t_1, x\right)\\
\mathbf{if}\;t_2 \leq -2.271715210522009 \cdot 10^{-255}:\\
\;\;\;\;t_3\\

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

\mathbf{elif}\;t_2 \leq 6.722453214872935 \cdot 10^{-48}:\\
\;\;\;\;\left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{x \cdot y}{a - z} + \frac{z \cdot t}{a - z}\right)\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* (- y z) (/ (- t x) (- a z)))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (- t x) (- a z)))
        (t_2 (+ x (* (- y z) t_1)))
        (t_3 (fma (- y z) t_1 x)))
   (if (<= t_2 -2.271715210522009e-255)
     t_3
     (if (<= t_2 0.0)
       (-
        (+ (/ (* x y) z) (+ t (/ (* t a) z)))
        (+ (/ (* y t) z) (/ (* x a) z)))
       (if (<= t_2 6.722453214872935e-48)
         (-
          (+ (/ (* x z) (- a z)) (+ x (/ (* y t) (- a z))))
          (+ (/ (* x y) (- a z)) (/ (* z t) (- a z))))
         t_3)))))
double code(double x, double y, double z, double t, double a) {
	return x + ((y - z) * ((t - x) / (a - z)));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (t - x) / (a - z);
	double t_2 = x + ((y - z) * t_1);
	double t_3 = fma((y - z), t_1, x);
	double tmp;
	if (t_2 <= -2.271715210522009e-255) {
		tmp = t_3;
	} else if (t_2 <= 0.0) {
		tmp = (((x * y) / z) + (t + ((t * a) / z))) - (((y * t) / z) + ((x * a) / z));
	} else if (t_2 <= 6.722453214872935e-48) {
		tmp = (((x * z) / (a - z)) + (x + ((y * t) / (a - z)))) - (((x * y) / (a - z)) + ((z * t) / (a - z)));
	} else {
		tmp = t_3;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Derivation

  1. Split input into 3 regimes
  2. if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -2.27171521052200888e-255 or 6.7224532148729354e-48 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z))))

    1. Initial program 4.6

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \]

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

    1. Initial program 59.6

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

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

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

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

    1. Initial program 16.2

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

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

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

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

Reproduce

herbie shell --seed 2022068 
(FPCore (x y z t a)
  :name "Numeric.Signal:interpolate   from hsignal-0.2.7.1"
  :precision binary64
  (+ x (* (- y z) (/ (- t x) (- a z)))))