?

Average Error: 6.5 → 3.3
Time: 8.2s
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 \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+298}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;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 (- 1.0 (/ y t)))
     (if (<= t_1 5e+298) t_1 (* 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 * (1.0 - (y / t));
	} else if (t_1 <= 5e+298) {
		tmp = t_1;
	} else {
		tmp = 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 * (1.0 - (y / t));
	} else if (t_1 <= 5e+298) {
		tmp = t_1;
	} else {
		tmp = 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 * (1.0 - (y / t))
	elif t_1 <= 5e+298:
		tmp = t_1
	else:
		tmp = 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(1.0 - Float64(y / t)));
	elseif (t_1 <= 5e+298)
		tmp = t_1;
	else
		tmp = 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 * (1.0 - (y / t));
	elseif (t_1 <= 5e+298)
		tmp = t_1;
	else
		tmp = 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[(1.0 - N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+298], t$95$1, N[(y * N[(N[(z - x), $MachinePrecision] / t), $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 \cdot \left(1 - \frac{y}{t}\right)\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+298}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;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.5
Target2.1
Herbie3.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. Taylor expanded in x around -inf 28.4

      \[\leadsto \color{blue}{-1 \cdot \left(\left(\frac{y}{t} - 1\right) \cdot x\right)} \]
    3. Simplified28.4

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

      [Start]28.4

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

      rational_best_oopsla_all_46_json_45_simplify-7 [=>]28.4

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]28.4

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

      rational_best_oopsla_all_46_json_45_simplify-74 [=>]28.4

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

      rational_best_oopsla_all_46_json_45_simplify-94 [<=]28.4

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

      rational_best_oopsla_all_46_json_45_simplify-93 [=>]28.4

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

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

    1. Initial program 0.9

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

    if 5.0000000000000003e298 < (+.f64 x (/.f64 (*.f64 y (-.f64 z x)) t))

    1. Initial program 54.1

      \[x + \frac{y \cdot \left(z - x\right)}{t} \]
    2. Taylor expanded in y around inf 22.9

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

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

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

Alternatives

Alternative 1
Error17.4
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -2.6 \cdot 10^{-137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-199}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error11.1
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -5.6 \cdot 10^{+114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-85}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error11.1
Cost712
\[\begin{array}{l} t_1 := x - \frac{y}{t} \cdot x\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{+114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-84}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error27.2
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-199}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error26.3
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{-135}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.38 \cdot 10^{-192}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error31.7
Cost64
\[x \]

Error

Reproduce?

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