?

Average Error: 6.6 → 4.0
Time: 22.4s
Precision: binary64
Cost: 2184

?

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original6.6
Target2.0
Herbie4.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. Taylor expanded in z around 0 62.3

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

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

      [Start]62.3

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

      rational.json-simplify-43 [=>]62.3

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

      rational.json-simplify-9 [=>]62.3

      \[ x + \frac{y \cdot \color{blue}{\left(-x\right)}}{t} \]
    4. Taylor expanded in x around -inf 27.9

      \[\leadsto \color{blue}{-1 \cdot \left(\left(\frac{y}{t} - 1\right) \cdot x\right)} \]
    5. Simplified27.9

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

      [Start]27.9

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

      rational.json-simplify-43 [=>]27.9

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

      rational.json-simplify-16 [=>]27.9

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

      rational.json-simplify-8 [<=]27.9

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

      rational.json-simplify-12 [=>]27.9

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

      rational.json-simplify-51 [=>]27.9

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

      rational.json-simplify-5 [=>]27.9

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

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

    1. Initial program 0.9

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

      \[\leadsto x + \frac{\color{blue}{y \cdot z + -1 \cdot \left(y \cdot x\right)}}{t} \]
    3. Applied egg-rr0.9

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

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

    1. Initial program 24.6

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

      \[\leadsto x + \frac{\color{blue}{y \cdot z + -1 \cdot \left(y \cdot x\right)}}{t} \]
    3. Applied egg-rr24.6

      \[\leadsto x + \frac{\color{blue}{y \cdot z - y \cdot x}}{t} \]
    4. Applied egg-rr56.2

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

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

      [Start]56.2

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

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

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

      rational.json-simplify-43 [<=]57.1

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

      rational.json-simplify-43 [=>]55.2

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

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

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

      [Start]17.3

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

      rational.json-simplify-1 [=>]17.3

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

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

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

      rational.json-simplify-9 [=>]17.3

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

      rational.json-simplify-43 [=>]17.3

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

      rational.json-simplify-9 [=>]17.3

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

      rational.json-simplify-12 [=>]17.3

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

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

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

      rational.json-simplify-48 [=>]17.2

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

      metadata-eval [=>]17.2

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

      rational.json-simplify-9 [=>]17.2

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

      rational.json-simplify-12 [=>]17.2

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

      rational.json-simplify-44 [=>]17.2

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

      metadata-eval [=>]17.2

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

      rational.json-simplify-5 [=>]17.2

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

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

Alternatives

Alternative 1
Error10.9
Cost976
\[\begin{array}{l} t_1 := x + \frac{y \cdot z}{t}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -2.7 \cdot 10^{+53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -6.5 \cdot 10^{-100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.8 \cdot 10^{-125}:\\ \;\;\;\;x + \frac{y \cdot \left(-x\right)}{t}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error6.0
Cost836
\[\begin{array}{l} \mathbf{if}\;x \leq 1.15 \cdot 10^{+15}:\\ \;\;\;\;x + \frac{y \cdot z - y \cdot x}{t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \end{array} \]
Alternative 3
Error10.5
Cost712
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -1.4 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-70}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error6.0
Cost708
\[\begin{array}{l} \mathbf{if}\;x \leq 7.8 \cdot 10^{+15}:\\ \;\;\;\;x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{y}{t}\right)\\ \end{array} \]
Alternative 5
Error30.3
Cost648
\[\begin{array}{l} \mathbf{if}\;t \leq -2.6 \cdot 10^{-73}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 6.2 \cdot 10^{-97}:\\ \;\;\;\;-\frac{y \cdot x}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error21.7
Cost448
\[x \cdot \left(1 - \frac{y}{t}\right) \]
Alternative 7
Error32.1
Cost64
\[x \]

Error

Reproduce?

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