Average Error: 6.6 → 1.2
Time: 9.8s
Precision: binary64
Cost: 1864
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + \frac{z - x}{\frac{t}{y}}\\ t_2 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+200}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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 (/ (- z x) (/ t y)))) (t_2 (+ x (/ (* y (- z x)) t))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+200) t_2 t_1))))
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 + ((z - x) / (t / y));
	double t_2 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 2e+200) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	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 + ((z - x) / (t / y));
	double t_2 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 2e+200) {
		tmp = t_2;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y * (z - x)) / t)
def code(x, y, z, t):
	t_1 = x + ((z - x) / (t / y))
	t_2 = x + ((y * (z - x)) / t)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 2e+200:
		tmp = t_2
	else:
		tmp = t_1
	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(z - x) / Float64(t / y)))
	t_2 = Float64(x + Float64(Float64(y * Float64(z - x)) / t))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 2e+200)
		tmp = t_2;
	else
		tmp = t_1;
	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 + ((z - x) / (t / y));
	t_2 = x + ((y * (z - x)) / t);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 2e+200)
		tmp = t_2;
	else
		tmp = t_1;
	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[(z - x), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+200], t$95$2, t$95$1]]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + \frac{z - x}{\frac{t}{y}}\\
t_2 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+200}:\\
\;\;\;\;t_2\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

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

    1. Initial program 30.1

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

      \[\leadsto x + \color{blue}{\left(z - x\right) \cdot \left(y \cdot \frac{1}{t}\right)} \]
    3. Taylor expanded in z around 0 30.1

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

      \[\leadsto x + \color{blue}{\frac{z - x}{\frac{t}{y}}} \]
      Proof
      (/.f64 (-.f64 z x) (/.f64 t y)): 0 points increase in error, 0 points decrease in error
      (Rewrite=> div-sub_binary64 (-.f64 (/.f64 z (/.f64 t y)) (/.f64 x (/.f64 t y)))): 2 points increase in error, 1 points decrease in error
      (-.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z y) t)) (/.f64 x (/.f64 t y))): 34 points increase in error, 27 points decrease in error
      (-.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y z)) t) (/.f64 x (/.f64 t y))): 0 points increase in error, 0 points decrease in error
      (-.f64 (/.f64 (*.f64 y z) t) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x y) t))): 31 points increase in error, 29 points decrease in error
      (-.f64 (/.f64 (*.f64 y z) t) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 y x)) t)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 y z) t) (neg.f64 (/.f64 (*.f64 y x) t)))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 y z) t) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (*.f64 y x) t)))): 0 points increase in error, 0 points decrease in error

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

    1. Initial program 0.9

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

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

Alternatives

Alternative 1
Error26.0
Cost1504
\[\begin{array}{l} t_1 := \frac{z - x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -2.5899090844563114 \cdot 10^{+43}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.7221776240232344 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.5344499294200258 \cdot 10^{-93}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.1160315341746628 \cdot 10^{-247}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq 7.117489626762571 \cdot 10^{-225}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.665641835090503 \cdot 10^{-60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.0009469850828766 \cdot 10^{-12}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.995464527869305 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error18.3
Cost976
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -1.5344499294200258 \cdot 10^{-93}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.1160315341746628 \cdot 10^{-247}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq 7.117489626762571 \cdot 10^{-225}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.665641835090503 \cdot 10^{-60}:\\ \;\;\;\;\frac{z - x}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error26.5
Cost848
\[\begin{array}{l} t_1 := \frac{z}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -1.5344499294200258 \cdot 10^{-93}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.1160315341746628 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.117489626762571 \cdot 10^{-225}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.665641835090503 \cdot 10^{-60}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error27.3
Cost848
\[\begin{array}{l} t_1 := \frac{y \cdot z}{t}\\ \mathbf{if}\;x \leq -1.5344499294200258 \cdot 10^{-93}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.1160315341746628 \cdot 10^{-247}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.117489626762571 \cdot 10^{-225}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.665641835090503 \cdot 10^{-60}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error10.6
Cost712
\[\begin{array}{l} t_1 := x - \frac{x}{\frac{t}{y}}\\ \mathbf{if}\;x \leq -1.5070423175891595 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.748330110748659 \cdot 10^{-10}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error2.1
Cost576
\[x + \frac{z - x}{\frac{t}{y}} \]
Alternative 7
Error31.9
Cost64
\[x \]

Error

Reproduce

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