?

Average Error: 6.3 → 0.8
Time: 16.7s
Precision: binary64
Cost: 1864

?

\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} t_1 := x + y \cdot \frac{z - x}{t}\\ t_2 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{+306}:\\ \;\;\;\;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 (* y (/ (- z x) t)))) (t_2 (+ x (/ (* y (- z x)) t))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+306) 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 + (y * ((z - x) / t));
	double t_2 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 5e+306) {
		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 + (y * ((z - x) / t));
	double t_2 = x + ((y * (z - x)) / t);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 5e+306) {
		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 + (y * ((z - x) / t))
	t_2 = x + ((y * (z - x)) / t)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 5e+306:
		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(y * Float64(Float64(z - x) / t)))
	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 <= 5e+306)
		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 + (y * ((z - x) / t));
	t_2 = x + ((y * (z - x)) / t);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 5e+306)
		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[(y * N[(N[(z - x), $MachinePrecision] / t), $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, 5e+306], t$95$2, t$95$1]]]]
x + \frac{y \cdot \left(z - x\right)}{t}
\begin{array}{l}
t_1 := x + y \cdot \frac{z - x}{t}\\
t_2 := x + \frac{y \cdot \left(z - x\right)}{t}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+306}:\\
\;\;\;\;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.3
Target2.0
Herbie0.8
\[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 4.99999999999999993e306 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 62.6

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

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

      [Start]62.6

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

      rational_best-simplify-2 [=>]62.6

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

      rational_best-simplify-47 [=>]0.7

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

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

    1. Initial program 0.8

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

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

Alternatives

Alternative 1
Error12.1
Cost1040
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ \mathbf{if}\;x \leq -1100000:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{elif}\;x \leq -1.22 \cdot 10^{-288}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-261}:\\ \;\;\;\;\frac{z - x}{t} \cdot y\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t + \left(-y\right)}{t}\\ \end{array} \]
Alternative 2
Error18.7
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -1.76 \cdot 10^{-84}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.4 \cdot 10^{-127}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-164}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error17.8
Cost976
\[\begin{array}{l} t_1 := \frac{z - x}{t} \cdot y\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -9.2 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{-127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-234}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error12.1
Cost976
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{t}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -870000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.85 \cdot 10^{-288}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-261}:\\ \;\;\;\;\frac{z - x}{t} \cdot y\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error28.0
Cost848
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;x \leq -9.2 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{-127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-234}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error27.8
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-137}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-234}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-164}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error27.9
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -9.2 \cdot 10^{-42}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-125}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-234}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-164}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error4.9
Cost840
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -1.06 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{+161}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error11.9
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -3750000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-164}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error1.8
Cost708
\[\begin{array}{l} \mathbf{if}\;y \leq 1.5 \cdot 10^{+106}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \end{array} \]
Alternative 11
Error31.5
Cost64
\[x \]

Error

Reproduce?

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