Average Error: 6.2 → 1.3
Time: 21.3s
Precision: binary64
Cost: 1992
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + y \cdot \left(\left(z - x\right) \cdot \frac{1}{t}\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+269}:\\ \;\;\;\;x + \frac{y \cdot z - x \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (+ x (/ (* y (- z x)) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ x (/ (* y (- z x)) t))))
   (if (<= t_1 (- INFINITY))
     (+ x (* y (* (- z x) (/ 1.0 t))))
     (if (<= t_1 2e+269)
       (+ x (/ (- (* y z) (* x y)) t))
       (+ x (* y (/ (- z x) t)))))))
double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
double code(double x, double y, double z, double t) {
	double t_1 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = x + (y * ((z - x) * (1.0 / t)));
	} else if (t_1 <= 2e+269) {
		tmp = x + (((y * z) - (x * y)) / t);
	} else {
		tmp = x + (y * ((z - x) / t));
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return x + ((y * (z - x)) / t);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = x + (y * ((z - x) * (1.0 / t)));
	} else if (t_1 <= 2e+269) {
		tmp = x + (((y * z) - (x * y)) / t);
	} else {
		tmp = x + (y * ((z - x) / t));
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
def code(x, y, z, t):
	t_1 = x + ((y * (z - x)) / t)
	tmp = 0
	if t_1 <= -math.inf:
		tmp = x + (y * ((z - x) * (1.0 / t)))
	elif t_1 <= 2e+269:
		tmp = x + (((y * z) - (x * y)) / t)
	else:
		tmp = x + (y * ((z - x) / t))
	return tmp
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * Float64(z - x)) / t))
end
function code(x, y, z, t)
	t_1 = Float64(x + Float64(Float64(y * Float64(z - x)) / t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(x + Float64(y * Float64(Float64(z - x) * Float64(1.0 / t))));
	elseif (t_1 <= 2e+269)
		tmp = Float64(x + Float64(Float64(Float64(y * z) - Float64(x * y)) / t));
	else
		tmp = Float64(x + Float64(y * Float64(Float64(z - x) / t)));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * (z - x)) / t);
end
function tmp_2 = code(x, y, z, t)
	t_1 = x + ((y * (z - x)) / t);
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = x + (y * ((z - x) * (1.0 / t)));
	elseif (t_1 <= 2e+269)
		tmp = x + (((y * z) - (x * y)) / t);
	else
		tmp = x + (y * ((z - x) / t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x + N[(y * N[(N[(z - x), $MachinePrecision] * N[(1.0 / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+269], N[(x + N[(N[(N[(y * z), $MachinePrecision] - N[(x * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(N[(z - x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + y \cdot \left(\left(z - x\right) \cdot \frac{1}{t}\right)\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+269}:\\
\;\;\;\;x + \frac{y \cdot z - x \cdot y}{t}\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot \frac{z - x}{t}\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.2
Target1.9
Herbie1.3
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

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

    1. Initial program 64.0

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Applied egg-rr0.2

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

    if -inf.0 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t)) < 2.0000000000000001e269

    1. Initial program 0.8

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

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

    if 2.0000000000000001e269 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 37.0

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Simplified8.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - x}{t}, x\right)} \]
      Proof
      (fma.f64 y (/.f64 (-.f64 z x) t) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (/.f64 (-.f64 z x) t)) x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 y (-.f64 z x)) t)) x): 45 points increase in error, 40 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))): 0 points increase in error, 0 points decrease in error
    3. Applied egg-rr8.6

      \[\leadsto \color{blue}{y \cdot \frac{z - x}{t} + x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.3

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

Alternatives

Alternative 1
Error1.3
Cost1864
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+269}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \end{array} \]
Alternative 2
Error1.3
Cost1864
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;x + y \cdot \left(\left(z - x\right) \cdot \frac{1}{t}\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+269}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \end{array} \]
Alternative 3
Error30.7
Cost1508
\[\begin{array}{l} t_1 := y \cdot \frac{-x}{t}\\ t_2 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -8.2 \cdot 10^{+174}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-17}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq -1.4487770150194654 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.960606829359411 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.9229633432047324 \cdot 10^{-139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 9.763836528016203 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error30.7
Cost1508
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -8.2 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+22}:\\ \;\;\;\;y \cdot \frac{-x}{t}\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-17}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq -1.4487770150194654 \cdot 10^{-24}:\\ \;\;\;\;\frac{x \cdot \left(-y\right)}{t}\\ \mathbf{elif}\;y \leq 5.960606829359411 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.9229633432047324 \cdot 10^{-139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 9.763836528016203 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error30.7
Cost1508
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -8.2 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+22}:\\ \;\;\;\;y \cdot \frac{-x}{t}\\ \mathbf{elif}\;y \leq -1.2 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.75 \cdot 10^{-17}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq -1.4487770150194654 \cdot 10^{-24}:\\ \;\;\;\;x \cdot \frac{-y}{t}\\ \mathbf{elif}\;y \leq 5.960606829359411 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.9229633432047324 \cdot 10^{-139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 9.763836528016203 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error21.9
Cost1240
\[\begin{array}{l} t_1 := x - \frac{y}{\frac{t}{x}}\\ \mathbf{if}\;x \leq -3.3979663456471364 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.656290067491686 \cdot 10^{-149}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq -1.654488913600169 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.2372071618114515 \cdot 10^{-78}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 7.931040074545743 \cdot 10^{-53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.329652243163698 \cdot 10^{-13}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error30.1
Cost1112
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;y \leq -1.05 \cdot 10^{+175}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.960606829359411 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.9229633432047324 \cdot 10^{-139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 9.763836528016203 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error30.1
Cost1112
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;y \leq -1.05 \cdot 10^{+175}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.960606829359411 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.9229633432047324 \cdot 10^{-139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 9.763836528016203 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error30.2
Cost1112
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ \mathbf{if}\;y \leq -4.4 \cdot 10^{+171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.960606829359411 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.9229633432047324 \cdot 10^{-139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 9.763836528016203 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error30.2
Cost1112
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;y \leq -8.2 \cdot 10^{+174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1.7 \cdot 10^{+66}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.22 \cdot 10^{+22}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;y \leq 5.960606829359411 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.9229633432047324 \cdot 10^{-139}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;y \leq 9.763836528016203 \cdot 10^{-92}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error19.8
Cost1108
\[\begin{array}{l} t_1 := \left(z - x\right) \cdot \frac{y}{t}\\ t_2 := x - \frac{y}{\frac{t}{x}}\\ \mathbf{if}\;x \leq -6.511587185880862 \cdot 10^{-91}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -4.656290067491686 \cdot 10^{-149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.654488913600169 \cdot 10^{-201}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.6562695282909414 \cdot 10^{-219}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;x \leq 4.89677638207611 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error11.5
Cost976
\[\begin{array}{l} t_1 := \left(z - x\right) \cdot \frac{y}{t}\\ t_2 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-41}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.6 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-110}:\\ \;\;\;\;x - \frac{x \cdot y}{t}\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 13
Error11.3
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-94}:\\ \;\;\;\;\left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 14
Error10.7
Cost712
\[\begin{array}{l} t_1 := x + y \cdot \frac{z}{t}\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 9.2 \cdot 10^{-94}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 15
Error26.7
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1153234915812872 \cdot 10^{-64}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9.329652243163698 \cdot 10^{-13}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 16
Error1.8
Cost576
\[x + \frac{z - x}{\frac{t}{y}} \]
Alternative 17
Error31.8
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022291 
(FPCore (x y z t)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, D"
  :precision binary64

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

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