?

Average Error: 10.23% → 1.58%
Time: 11.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 -5 \cdot 10^{+290}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+298}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \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 -5e+290)
     (+ x (/ (- z x) (/ t y)))
     (if (<= t_1 5e+298) t_1 (+ x (/ y (/ t (- z x))))))))
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 <= -5e+290) {
		tmp = x + ((z - x) / (t / y));
	} else if (t_1 <= 5e+298) {
		tmp = t_1;
	} else {
		tmp = x + (y / (t / (z - x)));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * (z - x)) / t)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + ((y * (z - x)) / t)
    if (t_1 <= (-5d+290)) then
        tmp = x + ((z - x) / (t / y))
    else if (t_1 <= 5d+298) then
        tmp = t_1
    else
        tmp = x + (y / (t / (z - x)))
    end if
    code = tmp
end function
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 <= -5e+290) {
		tmp = x + ((z - x) / (t / y));
	} else if (t_1 <= 5e+298) {
		tmp = t_1;
	} else {
		tmp = x + (y / (t / (z - x)));
	}
	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 <= -5e+290:
		tmp = x + ((z - x) / (t / y))
	elif t_1 <= 5e+298:
		tmp = t_1
	else:
		tmp = x + (y / (t / (z - x)))
	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 <= -5e+290)
		tmp = Float64(x + Float64(Float64(z - x) / Float64(t / y)));
	elseif (t_1 <= 5e+298)
		tmp = t_1;
	else
		tmp = Float64(x + Float64(y / Float64(t / Float64(z - x))));
	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 <= -5e+290)
		tmp = x + ((z - x) / (t / y));
	elseif (t_1 <= 5e+298)
		tmp = t_1;
	else
		tmp = x + (y / (t / (z - x)));
	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, -5e+290], N[(x + N[(N[(z - x), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+298], t$95$1, N[(x + N[(y / N[(t / N[(z - x), $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 -5 \cdot 10^{+290}:\\
\;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\

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

\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.23%
Target3.27%
Herbie1.58%
\[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)) < -4.9999999999999998e290

    1. Initial program 75.88

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

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

      [Start]75.88

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

      associate-*l/ [<=]2.27

      \[ x + \color{blue}{\frac{y}{t} \cdot \left(z - x\right)} \]
    3. Applied egg-rr2.02

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

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

    1. Initial program 1.39

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

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

    1. Initial program 84.59

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

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

      [Start]84.59

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

      associate-/l* [=>]4.34

      \[ x + \color{blue}{\frac{y}{\frac{t}{z - x}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.58

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \frac{y \cdot \left(z - x\right)}{t} \leq -5 \cdot 10^{+290}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \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}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \end{array} \]

Alternatives

Alternative 1
Error1.47%
Cost1865
\[\begin{array}{l} t_1 := x + \frac{y \cdot \left(z - x\right)}{t}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 5 \cdot 10^{+298}\right):\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error41.59%
Cost980
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;x \leq -4.1 \cdot 10^{-137}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-273}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-194}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error41.42%
Cost980
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \cdot 10^{-136}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-184}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq -2.9 \cdot 10^{-217}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-272}:\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{elif}\;x \leq 2.02 \cdot 10^{-184}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error35.93%
Cost976
\[\begin{array}{l} t_1 := y \cdot \frac{z - x}{t}\\ \mathbf{if}\;y \leq -20.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{-152}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{-109}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 1.76 \cdot 10^{-44}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error12.99%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{-176} \lor \neg \left(z \leq 9 \cdot 10^{-79}\right):\\ \;\;\;\;x + z \cdot \left(y \cdot \frac{1}{t}\right)\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{y}}\\ \end{array} \]
Alternative 6
Error3.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -4.3 \cdot 10^{-284} \lor \neg \left(t \leq 1.15 \cdot 10^{-241}\right):\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(z - x\right)}{t}\\ \end{array} \]
Alternative 7
Error16.89%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.25 \cdot 10^{+73} \lor \neg \left(y \leq 1.2 \cdot 10^{+60}\right):\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 8
Error17.42%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{+114} \lor \neg \left(x \leq 2 \cdot 10^{-84}\right):\\ \;\;\;\;x - x \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 9
Error16.48%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -2.4 \cdot 10^{-68} \lor \neg \left(x \leq 1.9 \cdot 10^{-84}\right):\\ \;\;\;\;x - \frac{x}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 10
Error40.51%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-138}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.36 \cdot 10^{-179}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error40.93%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -2.25 \cdot 10^{-136}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-185}:\\ \;\;\;\;\frac{y \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error49.5%
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)))