Average Error: 14.1 → 3.6
Time: 8.1s
Precision: binary64
\[x + \left(y - z\right) \cdot \frac{t - x}{a - z} \]
\[\begin{array}{l} t_1 := \frac{z}{a - z}\\ t_2 := \frac{y}{a - z}\\ t_3 := x \cdot t_1 + \left(\mathsf{fma}\left(t, t_2 - t_1, x\right) - x \cdot t_2\right)\\ t_4 := \frac{t - x}{a - z}\\ t_5 := x + \left(y - z\right) \cdot t_4\\ \mathbf{if}\;t_5 \leq -2 \cdot 10^{-299}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_5 \leq 0:\\ \;\;\;\;\mathsf{fma}\left(t_4, y, \mathsf{fma}\left(a, \frac{t - x}{z}, t\right)\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 (/ z (- a z)))
        (t_2 (/ y (- a z)))
        (t_3 (+ (* x t_1) (- (fma t (- t_2 t_1) x) (* x t_2))))
        (t_4 (/ (- t x) (- a z)))
        (t_5 (+ x (* (- y z) t_4))))
   (if (<= t_5 -2e-299)
     t_3
     (if (<= t_5 0.0) (fma t_4 y (fma a (/ (- t x) z) t)) 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 = z / (a - z);
	double t_2 = y / (a - z);
	double t_3 = (x * t_1) + (fma(t, (t_2 - t_1), x) - (x * t_2));
	double t_4 = (t - x) / (a - z);
	double t_5 = x + ((y - z) * t_4);
	double tmp;
	if (t_5 <= -2e-299) {
		tmp = t_3;
	} else if (t_5 <= 0.0) {
		tmp = fma(t_4, y, fma(a, ((t - x) / z), t));
	} else {
		tmp = t_3;
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z))))
end
function code(x, y, z, t, a)
	t_1 = Float64(z / Float64(a - z))
	t_2 = Float64(y / Float64(a - z))
	t_3 = Float64(Float64(x * t_1) + Float64(fma(t, Float64(t_2 - t_1), x) - Float64(x * t_2)))
	t_4 = Float64(Float64(t - x) / Float64(a - z))
	t_5 = Float64(x + Float64(Float64(y - z) * t_4))
	tmp = 0.0
	if (t_5 <= -2e-299)
		tmp = t_3;
	elseif (t_5 <= 0.0)
		tmp = fma(t_4, y, fma(a, Float64(Float64(t - x) / z), t));
	else
		tmp = t_3;
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(x * t$95$1), $MachinePrecision] + N[(N[(t * N[(t$95$2 - t$95$1), $MachinePrecision] + x), $MachinePrecision] - N[(x * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(x + N[(N[(y - z), $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, -2e-299], t$95$3, If[LessEqual[t$95$5, 0.0], N[(t$95$4 * y + N[(a * N[(N[(t - x), $MachinePrecision] / z), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]]]
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\begin{array}{l}
t_1 := \frac{z}{a - z}\\
t_2 := \frac{y}{a - z}\\
t_3 := x \cdot t_1 + \left(\mathsf{fma}\left(t, t_2 - t_1, x\right) - x \cdot t_2\right)\\
t_4 := \frac{t - x}{a - z}\\
t_5 := x + \left(y - z\right) \cdot t_4\\
\mathbf{if}\;t_5 \leq -2 \cdot 10^{-299}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_5 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(t_4, y, \mathsf{fma}\left(a, \frac{t - x}{z}, t\right)\right)\\

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


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -1.99999999999999998e-299 or 0.0 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z))))

    1. Initial program 7.3

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

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

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

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

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

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

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

    1. Initial program 61.3

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

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

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

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

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

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

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

Reproduce

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