Average Error: 2.5 → 1.8
Time: 16.7s
Precision: binary64
Cost: 1092
\[\frac{x - y}{z - y} \cdot t \]
\[\begin{array}{l} t_1 := \frac{x - y}{z - y}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot t\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (- x y) (- z y))))
   (if (<= t_1 (- INFINITY)) (/ (* x t) (- z y)) (* t_1 t))))
double code(double x, double y, double z, double t) {
	return ((x - y) / (z - y)) * t;
}
double code(double x, double y, double z, double t) {
	double t_1 = (x - y) / (z - y);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = (x * t) / (z - y);
	} else {
		tmp = t_1 * t;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return ((x - y) / (z - y)) * t;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (x - y) / (z - y);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = (x * t) / (z - y);
	} else {
		tmp = t_1 * t;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x - y) / (z - y)) * t
def code(x, y, z, t):
	t_1 = (x - y) / (z - y)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = (x * t) / (z - y)
	else:
		tmp = t_1 * t
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x - y) / Float64(z - y)) * t)
end
function code(x, y, z, t)
	t_1 = Float64(Float64(x - y) / Float64(z - y))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(Float64(x * t) / Float64(z - y));
	else
		tmp = Float64(t_1 * t);
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x - y) / (z - y)) * t;
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x - y) / (z - y);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = (x * t) / (z - y);
	else
		tmp = t_1 * t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(x * t), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t), $MachinePrecision]]]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
t_1 := \frac{x - y}{z - y}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\frac{x \cdot t}{z - y}\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.5
Target2.5
Herbie1.8
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 x y) (-.f64 z y)) < -inf.0

    1. Initial program 64.0

      \[\frac{x - y}{z - y} \cdot t \]
    2. Simplified0.4

      \[\leadsto \color{blue}{\left(x - y\right) \cdot \frac{t}{z - y}} \]
      Proof
      (*.f64 (-.f64 x y) (/.f64 t (-.f64 z y))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 (-.f64 x y) t) (-.f64 z y))): 1 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)): 0 points increase in error, 1 points decrease in error
    3. Taylor expanded in x around inf 0.2

      \[\leadsto \color{blue}{\frac{t \cdot x}{z - y}} \]

    if -inf.0 < (/.f64 (-.f64 x y) (-.f64 z y))

    1. Initial program 1.9

      \[\frac{x - y}{z - y} \cdot t \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{z - y} \leq -\infty:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \end{array} \]

Alternatives

Alternative 1
Error18.4
Cost1768
\[\begin{array}{l} t_1 := \frac{t}{y} \cdot \left(y - x\right)\\ t_2 := \frac{t}{\frac{z}{x - y}}\\ t_3 := \left(x - y\right) \cdot \frac{t}{z}\\ t_4 := \frac{t}{\frac{y - z}{y}}\\ \mathbf{if}\;y \leq -3 \cdot 10^{+136}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq -1.95 \cdot 10^{-36}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.8 \cdot 10^{-86}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-185}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-248}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-117}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 116000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 9.5 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{+256}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 2
Error18.2
Cost1768
\[\begin{array}{l} t_1 := \frac{t}{y} \cdot \left(y - x\right)\\ t_2 := \left(x - y\right) \cdot \frac{t}{z}\\ t_3 := \frac{t}{\frac{y - z}{y}}\\ t_4 := t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{+136}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -1.25 \cdot 10^{-34}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.9 \cdot 10^{-93}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-204}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-117}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{-48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 490000000000:\\ \;\;\;\;\frac{t}{\frac{z}{x - y}}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+36}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+43}:\\ \;\;\;\;\frac{t}{\frac{z - y}{x}}\\ \mathbf{elif}\;y \leq 1.8 \cdot 10^{+257}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 3
Error19.5
Cost1636
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{t}{z}\\ t_2 := t \cdot \left(1 - \frac{x}{y}\right)\\ t_3 := \frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{if}\;y \leq -7 \cdot 10^{+121}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -5.8 \cdot 10^{+90}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.8 \cdot 10^{-35}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -2.5 \cdot 10^{-111}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -5 \cdot 10^{-171}:\\ \;\;\;\;\frac{x \cdot t}{z}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{-48}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 7200000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error18.6
Cost1504
\[\begin{array}{l} t_1 := \frac{t}{y} \cdot \left(y - x\right)\\ t_2 := \frac{t}{\frac{z}{x - y}}\\ t_3 := \left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{+137}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.9 \cdot 10^{-85}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -2.7 \cdot 10^{-185}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-249}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-117}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+14}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 5
Error18.6
Cost1372
\[\begin{array}{l} t_1 := \frac{t}{y} \cdot \left(y - x\right)\\ t_2 := \left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{if}\;y \leq -6.2 \cdot 10^{+136}:\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \mathbf{elif}\;y \leq -5.4 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -5.7 \cdot 10^{-192}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-117}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 310000000:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 6
Error18.2
Cost1372
\[\begin{array}{l} t_1 := \left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{if}\;y \leq -2.5 \cdot 10^{+138}:\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \mathbf{elif}\;y \leq -7.8 \cdot 10^{-37}:\\ \;\;\;\;\frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{-86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -5.3 \cdot 10^{-195}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{-101}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 9.2 \cdot 10^{-49}:\\ \;\;\;\;\frac{t \cdot \left(y - x\right)}{y}\\ \mathbf{elif}\;y \leq 2.15 \cdot 10^{+16}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 7
Error18.4
Cost1372
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+136}:\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \mathbf{elif}\;y \leq -3 \cdot 10^{-61}:\\ \;\;\;\;\frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{elif}\;y \leq -3.4 \cdot 10^{-103}:\\ \;\;\;\;\frac{y \cdot t}{y - z}\\ \mathbf{elif}\;y \leq -7.2 \cdot 10^{-189}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-85}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-49}:\\ \;\;\;\;\frac{t \cdot \left(y - x\right)}{y}\\ \mathbf{elif}\;y \leq 1700000000000:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 8
Error19.0
Cost1372
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{+138}:\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \mathbf{elif}\;y \leq -1.65 \cdot 10^{-62}:\\ \;\;\;\;\frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-102}:\\ \;\;\;\;\frac{y \cdot t}{y - z}\\ \mathbf{elif}\;y \leq -1.62 \cdot 10^{-196}:\\ \;\;\;\;\frac{x \cdot t}{z - y}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-117}:\\ \;\;\;\;\frac{y - x}{\frac{z}{-t}}\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-48}:\\ \;\;\;\;\frac{t \cdot \left(y - x\right)}{y}\\ \mathbf{elif}\;y \leq 145000000:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 9
Error26.7
Cost1112
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.8 \cdot 10^{+91}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq -12000:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -9 \cdot 10^{-93}:\\ \;\;\;\;\frac{-y}{\frac{z}{t}}\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-114}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-19}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 10
Error18.1
Cost1108
\[\begin{array}{l} t_1 := \frac{t}{y} \cdot \left(y - x\right)\\ t_2 := \left(x - y\right) \cdot \frac{t}{z}\\ t_3 := t \cdot \frac{y}{y - z}\\ \mathbf{if}\;y \leq -2.7 \cdot 10^{+136}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -5.4 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-117}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{-49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.28 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 11
Error18.1
Cost976
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z - y}\\ t_2 := t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{if}\;y \leq -8.4 \cdot 10^{+132}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -3.8 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -3.9 \cdot 10^{-38}:\\ \;\;\;\;\frac{t}{y} \cdot \left(y - x\right)\\ \mathbf{elif}\;y \leq 5.2 \cdot 10^{-18}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error27.4
Cost849
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{+91} \lor \neg \left(y \leq -2.2 \cdot 10^{-114}\right) \land y \leq 8.2 \cdot 10^{-25}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 13
Error27.3
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{+90}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-114}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-21}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 14
Error27.3
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.3 \cdot 10^{+91}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-115}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3.25 \cdot 10^{-18}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Error27.3
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -3.8 \cdot 10^{+91}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-114}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 5.4 \cdot 10^{-21}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 16
Error7.4
Cost841
\[\begin{array}{l} \mathbf{if}\;y \leq -1.02 \cdot 10^{+139} \lor \neg \left(y \leq 1.3 \cdot 10^{+69}\right):\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \end{array} \]
Alternative 17
Error27.6
Cost716
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{-111}:\\ \;\;\;\;x \cdot \frac{-t}{y}\\ \mathbf{elif}\;y \leq 8.8 \cdot 10^{-18}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 18
Error27.7
Cost716
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{-111}:\\ \;\;\;\;\frac{x}{\frac{y}{-t}}\\ \mathbf{elif}\;y \leq 1.62 \cdot 10^{-24}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 19
Error18.7
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -8.4 \cdot 10^{+132} \lor \neg \left(y \leq 2.5 \cdot 10^{-21}\right):\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \end{array} \]
Alternative 20
Error22.5
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+146}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-17}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 21
Error39.9
Cost64
\[t \]

Error

Reproduce

herbie shell --seed 2022343 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (/ t (/ (- z y) (- x y)))

  (* (/ (- x y) (- z y)) t))