Average Error: 15.0 → 3.8
Time: 46.8s
Precision: binary64
Cost: 8904
\[x + \left(y - z\right) \cdot \frac{t - x}{a - z} \]
\[\begin{array}{l} t_1 := \mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)\\ t_2 := x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{-277}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-280}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (fma (- t x) (/ (- y z) (- a z)) x))
        (t_2 (+ x (* (- y z) (/ (- t x) (- a z))))))
   (if (<= t_2 -2e-277)
     t_1
     (if (<= t_2 2e-280) (+ t (/ (- x t) (/ z (- y a)))) t_1))))
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 = fma((t - x), ((y - z) / (a - z)), x);
	double t_2 = x + ((y - z) * ((t - x) / (a - z)));
	double tmp;
	if (t_2 <= -2e-277) {
		tmp = t_1;
	} else if (t_2 <= 2e-280) {
		tmp = t + ((x - t) / (z / (y - a)));
	} else {
		tmp = t_1;
	}
	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 = fma(Float64(t - x), Float64(Float64(y - z) / Float64(a - z)), x)
	t_2 = Float64(x + Float64(Float64(y - z) * Float64(Float64(t - x) / Float64(a - z))))
	tmp = 0.0
	if (t_2 <= -2e-277)
		tmp = t_1;
	elseif (t_2 <= 2e-280)
		tmp = Float64(t + Float64(Float64(x - t) / Float64(z / Float64(y - a))));
	else
		tmp = t_1;
	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[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y - z), $MachinePrecision] * N[(N[(t - x), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e-277], t$95$1, If[LessEqual[t$95$2, 2e-280], N[(t + N[(N[(x - t), $MachinePrecision] / N[(z / N[(y - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\begin{array}{l}
t_1 := \mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)\\
t_2 := x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\
\mathbf{if}\;t_2 \leq -2 \cdot 10^{-277}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{-280}:\\
\;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\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.99999999999999994e-277 or 1.9999999999999999e-280 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z))))

    1. Initial program 7.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(t - x, \frac{y - z}{a - z}, x\right)} \]
      Proof
      (fma.f64 (-.f64 t x) (/.f64 (-.f64 y z) (-.f64 a z)) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (-.f64 t x) (/.f64 (-.f64 y z) (-.f64 a z))) x)): 5 points increase in error, 3 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (-.f64 t x) (-.f64 y z)) (-.f64 a z))) x): 80 points increase in error, 16 points decrease in error
      (+.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 (-.f64 y z) (-.f64 t x))) (-.f64 a z)) x): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite<= associate-*r/_binary64 (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) x): 28 points increase in error, 77 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z))))): 0 points increase in error, 0 points decrease in error

    if -1.99999999999999994e-277 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 1.9999999999999999e-280

    1. Initial program 60.1

      \[x + \left(y - z\right) \cdot \frac{t - x}{a - z} \]
    2. Taylor expanded in z around inf 13.6

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

      \[\leadsto \color{blue}{t - \frac{t - x}{z} \cdot \left(y - a\right)} \]
      Proof
      (-.f64 t (*.f64 (/.f64 (-.f64 t x) z) (-.f64 y a))): 0 points increase in error, 0 points decrease in error
      (-.f64 t (Rewrite<= associate-/r/_binary64 (/.f64 (-.f64 t x) (/.f64 z (-.f64 y a))))): 19 points increase in error, 33 points decrease in error
      (-.f64 t (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (-.f64 t x) (-.f64 y a)) z))): 30 points increase in error, 26 points decrease in error
      (-.f64 t (/.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 y (-.f64 t x)) (*.f64 a (-.f64 t x)))) z)): 1 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 t (neg.f64 (/.f64 (-.f64 (*.f64 y (-.f64 t x)) (*.f64 a (-.f64 t x))) z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 t (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (-.f64 (*.f64 y (-.f64 t x)) (*.f64 a (-.f64 t x))) z)))): 0 points increase in error, 0 points decrease in error
      (+.f64 t (*.f64 -1 (Rewrite=> div-sub_binary64 (-.f64 (/.f64 (*.f64 y (-.f64 t x)) z) (/.f64 (*.f64 a (-.f64 t x)) z))))): 0 points increase in error, 1 points decrease in error
      (+.f64 t (Rewrite<= distribute-lft-out--_binary64 (-.f64 (*.f64 -1 (/.f64 (*.f64 y (-.f64 t x)) z)) (*.f64 -1 (/.f64 (*.f64 a (-.f64 t x)) z))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 t (*.f64 -1 (/.f64 (*.f64 y (-.f64 t x)) z))) (*.f64 -1 (/.f64 (*.f64 a (-.f64 t x)) z)))): 0 points increase in error, 0 points decrease in error
      (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 -1 (/.f64 (*.f64 y (-.f64 t x)) z)) t)) (*.f64 -1 (/.f64 (*.f64 a (-.f64 t x)) z))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr4.0

      \[\leadsto t - \color{blue}{\frac{t - x}{\frac{z}{y - a}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.8

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

Alternatives

Alternative 1
Error6.6
Cost2632
\[\begin{array}{l} t_1 := x + \frac{y - z}{\frac{a - z}{t - x}}\\ t_2 := x + \left(y - z\right) \cdot \frac{t - x}{a - z}\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{-277}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{-280}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error25.3
Cost1368
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ t_2 := t + x \cdot \frac{y - a}{z}\\ \mathbf{if}\;a \leq -0.55:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.5 \cdot 10^{-94}:\\ \;\;\;\;t \cdot \left(1 - \frac{y}{z}\right)\\ \mathbf{elif}\;a \leq -1.05 \cdot 10^{-111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-104}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-74}:\\ \;\;\;\;x - x \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 2.020167982026052 \cdot 10^{+24}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \end{array} \]
Alternative 3
Error22.9
Cost1368
\[\begin{array}{l} t_1 := t + x \cdot \frac{y - a}{z}\\ t_2 := x + t \cdot \frac{y - z}{a}\\ \mathbf{if}\;a \leq -6 \cdot 10^{-25}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -4.5 \cdot 10^{-94}:\\ \;\;\;\;t \cdot \left(1 - \frac{y}{z}\right)\\ \mathbf{elif}\;a \leq -1.05 \cdot 10^{-111}:\\ \;\;\;\;x + t \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-74}:\\ \;\;\;\;x - x \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 1.95 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error26.3
Cost1240
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ t_2 := t + x \cdot \frac{y}{z}\\ \mathbf{if}\;a \leq -0.55:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.5 \cdot 10^{-94}:\\ \;\;\;\;t \cdot \left(1 - \frac{y}{z}\right)\\ \mathbf{elif}\;a \leq -1.05 \cdot 10^{-111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-104}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-74}:\\ \;\;\;\;x - x \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 1.95 \cdot 10^{-24}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \end{array} \]
Alternative 5
Error19.1
Cost1232
\[\begin{array}{l} t_1 := t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{if}\;a \leq -6 \cdot 10^{-25}:\\ \;\;\;\;x + t \cdot \frac{y - z}{a}\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-74}:\\ \;\;\;\;x - x \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 2.020167982026052 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{t - x}{a}\\ \end{array} \]
Alternative 6
Error17.0
Cost1232
\[\begin{array}{l} t_1 := t + \frac{x - t}{\frac{z}{y - a}}\\ t_2 := x + \frac{y - z}{\frac{a}{t - x}}\\ \mathbf{if}\;a \leq -1 \cdot 10^{-40}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-74}:\\ \;\;\;\;x - x \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 2.020167982026052 \cdot 10^{+24}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error14.2
Cost1232
\[\begin{array}{l} t_1 := t + \frac{x - t}{\frac{z}{y - a}}\\ t_2 := x - t \cdot \frac{z - y}{a - z}\\ \mathbf{if}\;a \leq -1.05 \cdot 10^{-111}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-74}:\\ \;\;\;\;x - x \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 1.95 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error19.9
Cost1104
\[\begin{array}{l} t_1 := x + t \cdot \frac{y - z}{a}\\ \mathbf{if}\;a \leq -0.55:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.06 \cdot 10^{-104}:\\ \;\;\;\;t + \frac{y}{z} \cdot \left(x - t\right)\\ \mathbf{elif}\;a \leq 9.5 \cdot 10^{-74}:\\ \;\;\;\;x - x \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 1.95 \cdot 10^{-24}:\\ \;\;\;\;t - x \cdot \frac{a - y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error31.4
Cost976
\[\begin{array}{l} t_1 := x - x \cdot \frac{y}{a}\\ \mathbf{if}\;a \leq -3.5 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.7 \cdot 10^{-121}:\\ \;\;\;\;t \cdot \left(1 - \frac{y}{z}\right)\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-109}:\\ \;\;\;\;x \cdot \frac{y - a}{z}\\ \mathbf{elif}\;a \leq 3.383673854060607 \cdot 10^{+41}:\\ \;\;\;\;x + t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error28.1
Cost976
\[\begin{array}{l} t_1 := x + t \cdot \frac{y}{a}\\ \mathbf{if}\;a \leq -0.55:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.7 \cdot 10^{-121}:\\ \;\;\;\;t \cdot \left(1 - \frac{y}{z}\right)\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-109}:\\ \;\;\;\;x \cdot \frac{y - a}{z}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-9}:\\ \;\;\;\;x + t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error28.2
Cost976
\[\begin{array}{l} \mathbf{if}\;a \leq -0.55:\\ \;\;\;\;x + t \cdot \frac{y}{a}\\ \mathbf{elif}\;a \leq 3.7 \cdot 10^{-121}:\\ \;\;\;\;t \cdot \left(1 - \frac{y}{z}\right)\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-109}:\\ \;\;\;\;x \cdot \frac{y - a}{z}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-9}:\\ \;\;\;\;x + t\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{t}{a}\\ \end{array} \]
Alternative 12
Error19.6
Cost972
\[\begin{array}{l} \mathbf{if}\;a \leq -0.55:\\ \;\;\;\;x + t \cdot \frac{y - z}{a}\\ \mathbf{elif}\;a \leq 1.24 \cdot 10^{-200}:\\ \;\;\;\;t + \frac{y}{z} \cdot \left(x - t\right)\\ \mathbf{elif}\;a \leq 2.020167982026052 \cdot 10^{+24}:\\ \;\;\;\;t - x \cdot \frac{a - y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot \frac{y}{a}\\ \end{array} \]
Alternative 13
Error19.7
Cost972
\[\begin{array}{l} \mathbf{if}\;a \leq -0.55:\\ \;\;\;\;x + t \cdot \frac{y - z}{a}\\ \mathbf{elif}\;a \leq 1.24 \cdot 10^{-200}:\\ \;\;\;\;t + \frac{y}{z} \cdot \left(x - t\right)\\ \mathbf{elif}\;a \leq 2.020167982026052 \cdot 10^{+24}:\\ \;\;\;\;t - x \cdot \frac{a - y}{z}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{t - x}{a}\\ \end{array} \]
Alternative 14
Error36.2
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq -3.5 \cdot 10^{-46}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{-116}:\\ \;\;\;\;t\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-109}:\\ \;\;\;\;x \cdot \frac{y - a}{z}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-9}:\\ \;\;\;\;x + t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 15
Error33.6
Cost844
\[\begin{array}{l} \mathbf{if}\;a \leq -6 \cdot 10^{-25}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 3.7 \cdot 10^{-121}:\\ \;\;\;\;t \cdot \left(1 - \frac{y}{z}\right)\\ \mathbf{elif}\;a \leq 4.5 \cdot 10^{-109}:\\ \;\;\;\;x \cdot \frac{y - a}{z}\\ \mathbf{elif}\;a \leq 1.05 \cdot 10^{-9}:\\ \;\;\;\;x + t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 16
Error37.1
Cost328
\[\begin{array}{l} \mathbf{if}\;a \leq -3.5 \cdot 10^{-46}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 7.4 \cdot 10^{-100}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 17
Error45.8
Cost64
\[t \]

Error

Reproduce

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