Average Error: 6.7 → 3.0
Time: 8.3s
Precision: binary64
Cost: 708
\[x + \frac{y \cdot \left(z - x\right)}{t} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-221}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\ \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
 (if (<= y -1e-221) (+ x (/ y (/ t (- z x)))) (+ 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 tmp;
	if (y <= -1e-221) {
		tmp = x + (y / (t / (z - x)));
	} else {
		tmp = x + ((z - x) * (y / t));
	}
	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 (y <= (-1d-221)) then
        tmp = x + (y / (t / (z - x)))
    else
        tmp = x + ((z - x) * (y / t))
    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 (y <= -1e-221) {
		tmp = x + (y / (t / (z - x)));
	} 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):
	tmp = 0
	if y <= -1e-221:
		tmp = x + (y / (t / (z - x)))
	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)
	tmp = 0.0
	if (y <= -1e-221)
		tmp = Float64(x + Float64(y / Float64(t / Float64(z - x))));
	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)
	tmp = 0.0;
	if (y <= -1e-221)
		tmp = x + (y / (t / (z - x)));
	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_] := If[LessEqual[y, -1e-221], N[(x + N[(y / N[(t / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}
\mathbf{if}\;y \leq -1 \cdot 10^{-221}:\\
\;\;\;\;x + \frac{y}{\frac{t}{z - x}}\\

\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.7
Target2.0
Herbie3.0
\[x - \left(x \cdot \frac{y}{t} + \left(-z\right) \cdot \frac{y}{t}\right) \]

Derivation

  1. Split input into 2 regimes
  2. if y < -1.00000000000000002e-221

    1. Initial program 8.2

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

      \[\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))): 0 points increase in error, 0 points decrease in error

    if -1.00000000000000002e-221 < y

    1. Initial program 5.8

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

      \[\leadsto \color{blue}{x + \frac{y}{t} \cdot \left(z - x\right)} \]
      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))): 0 points increase in error, 0 points decrease in error
  3. Recombined 2 regimes into one program.
  4. Final simplification3.0

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

Alternatives

Alternative 1
Error30.2
Cost1176
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ \mathbf{if}\;y \leq -8 \cdot 10^{-80}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-64}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1020:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{+73}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+92}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+194}:\\ \;\;\;\;\frac{x}{t} \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error30.3
Cost1176
\[\begin{array}{l} t_1 := \frac{y}{\frac{t}{z}}\\ \mathbf{if}\;y \leq -2.9 \cdot 10^{-79}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-64}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 10800:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+71}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+92}:\\ \;\;\;\;z \cdot \frac{y}{t}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+194}:\\ \;\;\;\;\frac{x}{\frac{-t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error30.3
Cost850
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-79} \lor \neg \left(y \leq 2.8 \cdot 10^{-64}\right) \land \left(y \leq 27500 \lor \neg \left(y \leq 5.5 \cdot 10^{+184}\right)\right):\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error30.3
Cost849
\[\begin{array}{l} \mathbf{if}\;y \leq -2.25 \cdot 10^{-80}:\\ \;\;\;\;y \cdot \frac{z}{t}\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{-64}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 55000 \lor \neg \left(y \leq 1.25 \cdot 10^{+184}\right):\\ \;\;\;\;\frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error11.6
Cost845
\[\begin{array}{l} \mathbf{if}\;y \leq -5.4 \cdot 10^{+62} \lor \neg \left(y \leq 2.5 \cdot 10^{+73}\right) \land y \leq 4.2 \cdot 10^{+151}:\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \end{array} \]
Alternative 6
Error22.0
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{-81} \lor \neg \left(y \leq 2.7 \cdot 10^{-64}\right):\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error10.9
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -5.4 \cdot 10^{+62} \lor \neg \left(y \leq 4.2 \cdot 10^{+72}\right):\\ \;\;\;\;y \cdot \frac{z - x}{t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{t}\\ \end{array} \]
Alternative 8
Error8.0
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -3.05 \cdot 10^{-87} \lor \neg \left(z \leq 2 \cdot 10^{-90}\right):\\ \;\;\;\;x + z \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{t}{y}}\\ \end{array} \]
Alternative 9
Error2.0
Cost576
\[x + \left(z - x\right) \cdot \frac{y}{t} \]
Alternative 10
Error32.2
Cost64
\[x \]

Error

Reproduce

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