Average Error: 15.2 → 4.3
Time: 27.6s
Precision: binary64
Cost: 2889
\[x + \left(y - z\right) \cdot \frac{t - x}{a - z} \]
\[\begin{array}{l} t_1 := x + \left(z - y\right) \cdot \frac{x - t}{a - z}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-289} \lor \neg \left(t_1 \leq 10^{-256}\right):\\ \;\;\;\;x + \left(t - x\right) \cdot \left(\left(y - z\right) \cdot \frac{1}{a - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t + \left(t - x\right) \cdot \frac{a}{z}\right) + \frac{y}{z} \cdot \left(x - t\right)\\ \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 (+ x (* (- z y) (/ (- x t) (- a z))))))
   (if (or (<= t_1 -2e-289) (not (<= t_1 1e-256)))
     (+ x (* (- t x) (* (- y z) (/ 1.0 (- a z)))))
     (+ (+ t (* (- t x) (/ a z))) (* (/ y z) (- x t))))))
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 = x + ((z - y) * ((x - t) / (a - z)));
	double tmp;
	if ((t_1 <= -2e-289) || !(t_1 <= 1e-256)) {
		tmp = x + ((t - x) * ((y - z) * (1.0 / (a - z))));
	} else {
		tmp = (t + ((t - x) * (a / z))) + ((y / z) * (x - t));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x + ((y - z) * ((t - x) / (a - z)))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + ((z - y) * ((x - t) / (a - z)))
    if ((t_1 <= (-2d-289)) .or. (.not. (t_1 <= 1d-256))) then
        tmp = x + ((t - x) * ((y - z) * (1.0d0 / (a - z))))
    else
        tmp = (t + ((t - x) * (a / z))) + ((y / z) * (x - t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + ((y - z) * ((t - x) / (a - z)));
}
public static double code(double x, double y, double z, double t, double a) {
	double t_1 = x + ((z - y) * ((x - t) / (a - z)));
	double tmp;
	if ((t_1 <= -2e-289) || !(t_1 <= 1e-256)) {
		tmp = x + ((t - x) * ((y - z) * (1.0 / (a - z))));
	} else {
		tmp = (t + ((t - x) * (a / z))) + ((y / z) * (x - t));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x + ((y - z) * ((t - x) / (a - z)))
def code(x, y, z, t, a):
	t_1 = x + ((z - y) * ((x - t) / (a - z)))
	tmp = 0
	if (t_1 <= -2e-289) or not (t_1 <= 1e-256):
		tmp = x + ((t - x) * ((y - z) * (1.0 / (a - z))))
	else:
		tmp = (t + ((t - x) * (a / z))) + ((y / z) * (x - t))
	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(x + Float64(Float64(z - y) * Float64(Float64(x - t) / Float64(a - z))))
	tmp = 0.0
	if ((t_1 <= -2e-289) || !(t_1 <= 1e-256))
		tmp = Float64(x + Float64(Float64(t - x) * Float64(Float64(y - z) * Float64(1.0 / Float64(a - z)))));
	else
		tmp = Float64(Float64(t + Float64(Float64(t - x) * Float64(a / z))) + Float64(Float64(y / z) * Float64(x - t)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x + ((y - z) * ((t - x) / (a - z)));
end
function tmp_2 = code(x, y, z, t, a)
	t_1 = x + ((z - y) * ((x - t) / (a - z)));
	tmp = 0.0;
	if ((t_1 <= -2e-289) || ~((t_1 <= 1e-256)))
		tmp = x + ((t - x) * ((y - z) * (1.0 / (a - z))));
	else
		tmp = (t + ((t - x) * (a / z))) + ((y / z) * (x - t));
	end
	tmp_2 = 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[(x + N[(N[(z - y), $MachinePrecision] * N[(N[(x - t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -2e-289], N[Not[LessEqual[t$95$1, 1e-256]], $MachinePrecision]], N[(x + N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] * N[(1.0 / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t + N[(N[(t - x), $MachinePrecision] * N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y / z), $MachinePrecision] * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \left(y - z\right) \cdot \frac{t - x}{a - z}
\begin{array}{l}
t_1 := x + \left(z - y\right) \cdot \frac{x - t}{a - z}\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{-289} \lor \neg \left(t_1 \leq 10^{-256}\right):\\
\;\;\;\;x + \left(t - x\right) \cdot \left(\left(y - z\right) \cdot \frac{1}{a - z}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(t + \left(t - x\right) \cdot \frac{a}{z}\right) + \frac{y}{z} \cdot \left(x - t\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < -2e-289 or 9.99999999999999977e-257 < (+.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. Simplified18.5

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

      [Start]7.3

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

      associate-*r/ [=>]18.5

      \[ x + \color{blue}{\frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}} \]
    3. Applied egg-rr4.1

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

    if -2e-289 < (+.f64 x (*.f64 (-.f64 y z) (/.f64 (-.f64 t x) (-.f64 a z)))) < 9.99999999999999977e-257

    1. Initial program 58.4

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

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

      [Start]58.4

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

      +-commutative [=>]58.4

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

      fma-def [=>]58.1

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

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

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

      [Start]13.5

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

      +-commutative [=>]13.5

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

      mul-1-neg [=>]13.5

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

      unsub-neg [=>]13.5

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

      associate-*l/ [<=]10.3

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

      associate-*l/ [<=]5.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(z - y\right) \cdot \frac{x - t}{a - z} \leq -2 \cdot 10^{-289} \lor \neg \left(x + \left(z - y\right) \cdot \frac{x - t}{a - z} \leq 10^{-256}\right):\\ \;\;\;\;x + \left(t - x\right) \cdot \left(\left(y - z\right) \cdot \frac{1}{a - z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t + \left(t - x\right) \cdot \frac{a}{z}\right) + \frac{y}{z} \cdot \left(x - t\right)\\ \end{array} \]

Alternatives

Alternative 1
Error8.9
Cost4432
\[\begin{array}{l} t_1 := x + \left(z - y\right) \cdot \frac{x - t}{a - z}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 10^{-256}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{elif}\;t_1 \leq 10^{+16}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+73}:\\ \;\;\;\;t + \frac{\left(t - x\right) \cdot \left(a - y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error8.8
Cost4432
\[\begin{array}{l} t_1 := x + \frac{y - z}{\frac{a - z}{t - x}}\\ t_2 := x + \left(z - y\right) \cdot \frac{x - t}{a - z}\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 10^{-256}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{elif}\;t_2 \leq 10^{+16}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+73}:\\ \;\;\;\;t + \frac{\left(t - x\right) \cdot \left(a - y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error8.8
Cost4432
\[\begin{array}{l} t_1 := x + \frac{y - z}{\frac{a - z}{t - x}}\\ t_2 := x + \left(z - y\right) \cdot \frac{x - t}{a - z}\\ \mathbf{if}\;t_2 \leq -2 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 10^{-256}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{elif}\;t_2 \leq 10^{+16}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+73}:\\ \;\;\;\;t + \left(\left(y - a\right) \cdot \frac{1}{z}\right) \cdot \left(x - t\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error4.4
Cost2761
\[\begin{array}{l} t_1 := x + \left(z - y\right) \cdot \frac{x - t}{a - z}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-289} \lor \neg \left(t_1 \leq 10^{-256}\right):\\ \;\;\;\;x + \left(t - x\right) \cdot \left(\left(y - z\right) \cdot \frac{1}{a - z}\right)\\ \mathbf{else}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \end{array} \]
Alternative 5
Error7.7
Cost2633
\[\begin{array}{l} t_1 := x + \left(z - y\right) \cdot \frac{x - t}{a - z}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-159} \lor \neg \left(t_1 \leq 2 \cdot 10^{-248}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \end{array} \]
Alternative 6
Error32.2
Cost1240
\[\begin{array}{l} t_1 := x + \frac{y \cdot t}{a}\\ \mathbf{if}\;a \leq -1.18 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -5.5 \cdot 10^{+54}:\\ \;\;\;\;\frac{t}{\frac{z - a}{z}}\\ \mathbf{elif}\;a \leq -5.3 \cdot 10^{+25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -2.4 \cdot 10^{-151}:\\ \;\;\;\;\frac{-t}{\frac{z}{y - z}}\\ \mathbf{elif}\;a \leq -9.5 \cdot 10^{-188}:\\ \;\;\;\;\frac{x \cdot \left(y - a\right)}{z}\\ \mathbf{elif}\;a \leq 2.4 \cdot 10^{+26}:\\ \;\;\;\;t - x \cdot \frac{a}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error14.6
Cost1234
\[\begin{array}{l} \mathbf{if}\;a \leq -1.02 \cdot 10^{+139} \lor \neg \left(a \leq -6.5 \cdot 10^{+116} \lor \neg \left(a \leq -2.8 \cdot 10^{-89}\right) \land a \leq 2.65 \cdot 10^{+26}\right):\\ \;\;\;\;x + \frac{t}{\frac{a - z}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \end{array} \]
Alternative 8
Error26.2
Cost1104
\[\begin{array}{l} t_1 := x + \frac{y \cdot t}{a}\\ t_2 := t \cdot \frac{y - z}{a - z}\\ \mathbf{if}\;z \leq -6.9 \cdot 10^{-15}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.9 \cdot 10^{-170}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-194}:\\ \;\;\;\;y \cdot \frac{t - x}{a - z}\\ \mathbf{elif}\;z \leq 0.0017:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error19.5
Cost972
\[\begin{array}{l} t_1 := t \cdot \frac{y - z}{a - z}\\ \mathbf{if}\;z \leq -5.8 \cdot 10^{+169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8 \cdot 10^{-150}:\\ \;\;\;\;x + \frac{t}{\frac{a - z}{y - z}}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-31}:\\ \;\;\;\;x + \frac{t - x}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error15.5
Cost969
\[\begin{array}{l} \mathbf{if}\;a \leq -2.65 \cdot 10^{-89} \lor \neg \left(a \leq 2.2 \cdot 10^{-56}\right):\\ \;\;\;\;x + \frac{t}{\frac{a - z}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;t + \frac{\left(t - x\right) \cdot \left(a - y\right)}{z}\\ \end{array} \]
Alternative 11
Error26.0
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -2.2 \cdot 10^{-15} \lor \neg \left(z \leq 0.017\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot t}{a}\\ \end{array} \]
Alternative 12
Error22.0
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5 \cdot 10^{-9} \lor \neg \left(z \leq 3.2 \cdot 10^{-8}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{y}{a} \cdot \left(x - t\right)\\ \end{array} \]
Alternative 13
Error22.1
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -3.4 \cdot 10^{-14} \lor \neg \left(z \leq 6.5 \cdot 10^{-13}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t - x}{\frac{a}{y}}\\ \end{array} \]
Alternative 14
Error29.7
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{-14} \lor \neg \left(z \leq 0.078\right):\\ \;\;\;\;\frac{t}{\frac{z - a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot t}{a}\\ \end{array} \]
Alternative 15
Error30.9
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -9 \cdot 10^{+60}:\\ \;\;\;\;t + \frac{a}{\frac{z}{t}}\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{+15}:\\ \;\;\;\;x + \frac{y \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 16
Error29.3
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -3 \cdot 10^{-14}:\\ \;\;\;\;\frac{t}{\frac{z - a}{z}}\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{+15}:\\ \;\;\;\;x + \frac{y \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;t - x \cdot \frac{a}{z}\\ \end{array} \]
Alternative 17
Error36.2
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-14}:\\ \;\;\;\;t + \frac{a}{\frac{z}{t}}\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 18
Error36.2
Cost328
\[\begin{array}{l} \mathbf{if}\;z \leq -1.22 \cdot 10^{-14}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq 3.05 \cdot 10^{+22}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 19
Error45.8
Cost64
\[t \]

Error

Reproduce

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