Average Error: 5.9 → 2.5
Time: 8.4s
Precision: binary64
Cost: 840
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq 1.65 \cdot 10^{-251}:\\ \;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\ \mathbf{elif}\;t \leq 1.25 \cdot 10^{+119}:\\ \;\;\;\;x + \frac{\left(z - x\right) \cdot y}{t}\\ \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
 (if (<= t 1.65e-251)
   (+ x (/ (- z x) (/ t y)))
   (if (<= t 1.25e+119) (+ x (/ (* (- z x) y) t)) (+ 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 tmp;
	if (t <= 1.65e-251) {
		tmp = x + ((z - x) / (t / y));
	} else if (t <= 1.25e+119) {
		tmp = x + (((z - x) * y) / t);
	} 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) :: tmp
    if (t <= 1.65d-251) then
        tmp = x + ((z - x) / (t / y))
    else if (t <= 1.25d+119) then
        tmp = x + (((z - x) * y) / t)
    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 tmp;
	if (t <= 1.65e-251) {
		tmp = x + ((z - x) / (t / y));
	} else if (t <= 1.25e+119) {
		tmp = x + (((z - x) * y) / t);
	} 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):
	tmp = 0
	if t <= 1.65e-251:
		tmp = x + ((z - x) / (t / y))
	elif t <= 1.25e+119:
		tmp = x + (((z - x) * y) / t)
	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)
	tmp = 0.0
	if (t <= 1.65e-251)
		tmp = Float64(x + Float64(Float64(z - x) / Float64(t / y)));
	elseif (t <= 1.25e+119)
		tmp = Float64(x + Float64(Float64(Float64(z - x) * y) / t));
	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)
	tmp = 0.0;
	if (t <= 1.65e-251)
		tmp = x + ((z - x) / (t / y));
	elseif (t <= 1.25e+119)
		tmp = x + (((z - x) * y) / t);
	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_] := If[LessEqual[t, 1.65e-251], N[(x + N[(N[(z - x), $MachinePrecision] / N[(t / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.25e+119], N[(x + N[(N[(N[(z - x), $MachinePrecision] * y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], 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}
\mathbf{if}\;t \leq 1.65 \cdot 10^{-251}:\\
\;\;\;\;x + \frac{z - x}{\frac{t}{y}}\\

\mathbf{elif}\;t \leq 1.25 \cdot 10^{+119}:\\
\;\;\;\;x + \frac{\left(z - x\right) \cdot y}{t}\\

\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

Original5.9
Target2.2
Herbie2.5
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Split input into 3 regimes
  2. if t < 1.65e-251

    1. Initial program 5.7

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

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
      Proof
      (+.f64 x (*.f64 (/.f64 y t) (-.f64 z x))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 y (-.f64 z x)) t))): 40 points increase in error, 25 points decrease in error
    3. Applied egg-rr2.5

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

    if 1.65e-251 < t < 1.25e119

    1. Initial program 3.1

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

    if 1.25e119 < t

    1. Initial program 10.4

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

      \[\leadsto \color{blue}{x + \frac{y}{\frac{t}{z - x}}} \]
      Proof
      (+.f64 x (/.f64 y (/.f64 t (-.f64 z x)))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 y (-.f64 z x)) t))): 36 points increase in error, 42 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification2.5

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

Alternatives

Alternative 1
Error19.5
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -1.8 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-239}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-159}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-20}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error17.2
Cost976
\[\begin{array}{l} t_1 := y \cdot \frac{z - x}{t}\\ t_2 := x \cdot \left(1 - \frac{y}{t}\right)\\ \mathbf{if}\;x \leq -2.7 \cdot 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-239}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-166}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 4.05 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error27.2
Cost848
\[\begin{array}{l} t_1 := y \cdot \frac{z}{t}\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{-111}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-239}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-160}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error26.2
Cost848
\[\begin{array}{l} t_1 := z \cdot \frac{y}{t}\\ \mathbf{if}\;x \leq -1.5 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-175}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error26.3
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -4.5 \cdot 10^{-109}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-175}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;x \leq 2.95 \cdot 10^{-158}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-19}:\\ \;\;\;\;\frac{z}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error2.4
Cost840
\[\begin{array}{l} t_1 := x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{if}\;z \leq -2 \cdot 10^{-147}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-123}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error2.5
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq 8.2 \cdot 10^{-257}:\\ \;\;\;\;x + \left(z - x\right) \cdot \frac{y}{t}\\ \mathbf{elif}\;t \leq 5 \cdot 10^{+120}:\\ \;\;\;\;x + \frac{\left(z - x\right) \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \end{array} \]
Alternative 8
Error11.1
Cost712
\[\begin{array}{l} t_1 := y \cdot \frac{z - x}{t}\\ \mathbf{if}\;y \leq -1.75 \cdot 10^{+139}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+174}:\\ \;\;\;\;x + \frac{z \cdot y}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error11.1
Cost712
\[\begin{array}{l} t_1 := x + \frac{z \cdot y}{t}\\ \mathbf{if}\;z \leq -2.1 \cdot 10^{-205}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-62}:\\ \;\;\;\;x - \frac{y}{\frac{t}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error2.2
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 11
Error30.8
Cost64
\[x \]

Error

Reproduce

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