Average Error: 12.6 → 4.7
Time: 20.6s
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\\ \mathbf{if}\;t_2 \leq -2.3944016139848967 \cdot 10^{-61}:\\ \;\;\;\;\mathsf{fma}\left(y - z, t_1, x\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \frac{x \cdot z}{a - z}\\ t_4 := \frac{z \cdot t}{a - z}\\ \mathbf{if}\;t_2 \leq -2.353607447213978 \cdot 10^{-275}:\\ \;\;\;\;\left(t_3 + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{1}{\frac{a - z}{x \cdot y}} + t_4\right)\\ \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 1.0267261529479653 \cdot 10^{+100}:\\ \;\;\;\;\left(t_3 + \left(x + t \cdot \frac{y}{a - z}\right)\right) - \left(t_4 + \frac{x \cdot y}{a - z}\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \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\\
\mathbf{if}\;t_2 \leq -2.3944016139848967 \cdot 10^{-61}:\\
\;\;\;\;\mathsf{fma}\left(y - z, t_1, x\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \frac{x \cdot z}{a - z}\\
t_4 := \frac{z \cdot t}{a - z}\\
\mathbf{if}\;t_2 \leq -2.353607447213978 \cdot 10^{-275}:\\
\;\;\;\;\left(t_3 + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{1}{\frac{a - z}{x \cdot y}} + t_4\right)\\

\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 1.0267261529479653 \cdot 10^{+100}:\\
\;\;\;\;\left(t_3 + \left(x + t \cdot \frac{y}{a - z}\right)\right) - \left(t_4 + \frac{x \cdot y}{a - z}\right)\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}\\


\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))))
   (if (<= t_2 -2.3944016139848967e-61)
     (fma (- y z) t_1 x)
     (let* ((t_3 (/ (* x z) (- a z))) (t_4 (/ (* z t) (- a z))))
       (if (<= t_2 -2.353607447213978e-275)
         (-
          (+ t_3 (+ x (/ (* y t) (- a z))))
          (+ (/ 1.0 (/ (- a z) (* x y))) t_4))
         (if (<= t_2 0.0)
           (-
            (+ (/ (* x y) z) (+ t (/ (* t a) z)))
            (+ (/ (* y t) z) (/ (* x a) z)))
           (if (<= t_2 1.0267261529479653e+100)
             (- (+ t_3 (+ x (* t (/ y (- a z))))) (+ t_4 (/ (* x y) (- a z))))
             t_2)))))))
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 tmp;
	if (t_2 <= -2.3944016139848967e-61) {
		tmp = fma((y - z), t_1, x);
	} else {
		double t_3 = (x * z) / (a - z);
		double t_4 = (z * t) / (a - z);
		double tmp_1;
		if (t_2 <= -2.353607447213978e-275) {
			tmp_1 = (t_3 + (x + ((y * t) / (a - z)))) - ((1.0 / ((a - z) / (x * y))) + t_4);
		} else if (t_2 <= 0.0) {
			tmp_1 = (((x * y) / z) + (t + ((t * a) / z))) - (((y * t) / z) + ((x * a) / z));
		} else if (t_2 <= 1.0267261529479653e+100) {
			tmp_1 = (t_3 + (x + (t * (y / (a - z))))) - (t_4 + ((x * y) / (a - z)));
		} else {
			tmp_1 = t_2;
		}
		tmp = tmp_1;
	}
	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 5 regimes
  2. if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -2.39440161398489666e-61

    1. Initial program 3.5

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

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

    if -2.39440161398489666e-61 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -2.3536074472139779e-275

    1. Initial program 15.5

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

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

      \[\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)} \]
    4. Applied clear-num_binary642.3

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

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

    1. Initial program 60.5

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

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

      \[\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)))) < 1.02672615294796529e100

    1. Initial program 9.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - z, \frac{t - x}{a - z}, x\right)} \]
    3. Taylor expanded in y around 0 4.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)} \]
    4. Applied associate-/l*_binary644.8

      \[\leadsto \left(\frac{z \cdot x}{a - z} + \left(\color{blue}{\frac{y}{\frac{a - z}{t}}} + x\right)\right) - \left(\frac{y \cdot x}{a - z} + \frac{t \cdot z}{a - z}\right) \]
    5. Applied associate-/r/_binary644.1

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

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

    1. Initial program 4.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(y - z\right) \cdot \frac{t - x}{a - z} \leq -2.3944016139848967 \cdot 10^{-61}:\\ \;\;\;\;\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 -2.353607447213978 \cdot 10^{-275}:\\ \;\;\;\;\left(\frac{x \cdot z}{a - z} + \left(x + \frac{y \cdot t}{a - z}\right)\right) - \left(\frac{1}{\frac{a - z}{x \cdot y}} + \frac{z \cdot t}{a - z}\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 1.0267261529479653 \cdot 10^{+100}:\\ \;\;\;\;\left(\frac{x \cdot z}{a - z} + \left(x + t \cdot \frac{y}{a - z}\right)\right) - \left(\frac{z \cdot t}{a - z} + \frac{x \cdot y}{a - z}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\ \end{array} \]

Reproduce

herbie shell --seed 2022088 
(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)))))