?

Average Error: 6.5 → 1.0
Time: 15.0s
Precision: binary64
Cost: 1864

?

\[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 \frac{z - x}{t}\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+253}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{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) t)))
     (if (<= t_1 2e+253) t_1 (+ x (* (- z x) (/ y 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) / t));
	} else if (t_1 <= 2e+253) {
		tmp = t_1;
	} else {
		tmp = x + ((z - x) * (y / 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) / t));
	} else if (t_1 <= 2e+253) {
		tmp = t_1;
	} else {
		tmp = x + ((z - x) * (y / 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) / t))
	elif t_1 <= 2e+253:
		tmp = t_1
	else:
		tmp = x + ((z - x) * (y / 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) / t)));
	elseif (t_1 <= 2e+253)
		tmp = t_1;
	else
		tmp = Float64(x + Float64(Float64(z - x) * Float64(y / 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) / t));
	elseif (t_1 <= 2e+253)
		tmp = t_1;
	else
		tmp = x + ((z - x) * (y / 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] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+253], t$95$1, N[(x + N[(N[(z - x), $MachinePrecision] * N[(y / 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 \frac{z - x}{t}\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+253}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.5
Target2.2
Herbie1.0
\[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. Simplified0.2

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

      [Start]64.0

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

      rational.json-simplify-2 [=>]64.0

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

      rational.json-simplify-49 [=>]0.2

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

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

    1. Initial program 0.8

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

    if 1.9999999999999999e253 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 28.7

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

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

      [Start]28.7

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

      rational.json-simplify-49 [=>]3.1

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

    \[\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 2 \cdot 10^{+253}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \end{array} \]

Alternatives

Alternative 1
Error30.1
Cost1112
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -5.6 \cdot 10^{+110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.15 \cdot 10^{-244}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-262}:\\ \;\;\;\;x \cdot \frac{y}{-t}\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-41}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 10^{+79}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{+127}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error6.9
Cost972
\[\begin{array}{l} t_1 := x + y \cdot \frac{z - x}{t}\\ \mathbf{if}\;x \leq -1 \cdot 10^{-189}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-269}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-28}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \end{array} \]
Alternative 3
Error18.3
Cost844
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -6 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -9 \cdot 10^{-136}:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{elif}\;x \leq 2.65 \cdot 10^{-244}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error2.0
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq 10^{-41}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+216}:\\ \;\;\;\;x + y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t} \cdot \left(z - x\right)\\ \end{array} \]
Alternative 5
Error2.0
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq 6.8 \cdot 10^{-41}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+216}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{t} \cdot \left(z - x\right)\\ \end{array} \]
Alternative 6
Error19.0
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -6 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-244}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error16.8
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -6 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-212}:\\ \;\;\;\;\frac{y}{t} \cdot \left(z - x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error10.7
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -2.1 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-35}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error10.5
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -2.2 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.58 \cdot 10^{-27}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error27.8
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-243}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error26.6
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -6 \cdot 10^{-51}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-210}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error31.9
Cost64
\[x \]

Error

Reproduce?

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